[native] Trigger NodeHeightMeasurer when font scale changes
Summary:
Resolves ENG-1632. This diff addresses the scenario when a user changes font scale in system settings while the Comm app is in background. In this case, when returned to the app, the message heights measured by NodeHeightMeasurer were wrong.
I solved this by creating an app state listener which is triggered when the app comes from background to foreground, and then it compares the current system font scale with the last known value. If they're different, it triggers a complete measurement.
NodeHeightMeasurer utilizes various React component lifecycle methods to do its job. According to this diagram and the current component logic, the best way to trigger full measurement is to reuse its constructor code and recreate its "initial" state from props. This is why I extracted this code to a separate static method and used it in both the constructor and event listener.
Side note: I noticed that the NodeHeightMeasurer is a very complicated component that has very little to no comments on how it works, making it difficult to understand. I added a few minimal comments to make at least my part more understandable.
Test Plan:
Tested in iOS Simulator by debugging the component lifecycle (console.log works too) while doing the following steps:
- opening the app
- swiping it to the background, opening Settings -> Accessibility -> Screen and text size -> Bigger text -> sliding the slider at the bottom
- going back to the app and observing the console
Note that for the first time, the log warnings about height inconsistencies can still occur, but then the component is re-rendered again and these warnings disappear. This happens because one re-render can happen even before the new measurement completes. This should not be an issue though.
Reviewers: tomek, ashoat, atul
Reviewed By: tomek, ashoat
Subscribers: ashoat, tomek, atul, abosh
Differential Revision: https://phab.comm.dev/D5475