This update introduces a new method for checking internet connectivity on the client side using the react-native-community/netinfo library. This approach is significantly faster than the previous method, which relied on HTTP polling to the backend. By using the observer design pattern, we can now monitor internet connectivity in real time without server-side dependence.
Changes
Removed the old HTTP polling method for checking connectivity.
Added new service NetworkStatusService.js
Added new React hook NetworkStatusObserver.js
Made various component adhere to using network status service
Added unit test for NetworkStatusService.js
Added smoother offline banner animation
Updated ESLint to work with ECMAScript 2022
Dependency added: react-native-community/netinfo version 9.5.0.
Related Issues
None.
Checklist
[x] Code has been tested locally and passes all relevant tests.
[x] Documentation has been updated to reflect the changes, if applicable.
[x] Code follows the established coding style and guidelines of the project.
[x] All new and existing tests related to the changes have passed.
[x] Any necessary dependencies or new packages have been properly documented.
[x] Pull request title and description are clear and descriptive.
[x] Reviewers have been assigned to the pull request.
[x] Any potential security implications have been considered and addressed.
[x] Performance impact of the changes has been evaluated, if relevant.
Screenshots (if applicable)
If mobile/frontend pull request, what version of the backend is it stable, and running on?
Branch: dev
Notes for Reviewers
As in prior versions, to simulate offline mode was done by closing the backend. Going into offline mode can now be done by going in airplane mode or disconnecting from wifi or mobile data. In order to debug in offline mode, set #simulateOffline to true inside NetworkStatusService.js, that way you won't lose connection to Expo
Description
This update introduces a new method for checking internet connectivity on the client side using the
react-native-community/netinfo
library. This approach is significantly faster than the previous method, which relied on HTTP polling to the backend. By using the observer design pattern, we can now monitor internet connectivity in real time without server-side dependence.Changes
NetworkStatusService.js
NetworkStatusObserver.js
NetworkStatusService.js
react-native-community/netinfo
version 9.5.0.Related Issues
None.
Checklist
Screenshots (if applicable)
If mobile/frontend pull request, what version of the backend is it stable, and running on?
Branch:
dev
Notes for Reviewers
As in prior versions, to simulate offline mode was done by closing the backend. Going into offline mode can now be done by going in airplane mode or disconnecting from wifi or mobile data. In order to debug in offline mode, set
#simulateOffline
totrue
insideNetworkStatusService.js
, that way you won't lose connection to Expo