(cherry picked from commit 0e81e0e2a8)
Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
This commit is contained in:
parent
e1329d41a3
commit
286f05c3be
1 changed files with 6 additions and 5 deletions
|
|
@ -111,10 +111,7 @@ const NetworkIndicator = ({
|
|||
};
|
||||
|
||||
const handleConnectionChange = ({hasInternet}: ConnectionChangedEvent) => {
|
||||
if (firstRun.current) {
|
||||
firstRun.current = false;
|
||||
handleWebSocket(true);
|
||||
} else {
|
||||
if (!firstRun.current) {
|
||||
if (!hasInternet) {
|
||||
setConnected(false);
|
||||
}
|
||||
|
|
@ -150,6 +147,11 @@ const NetworkIndicator = ({
|
|||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
handleWebSocket(true);
|
||||
firstRun.current = false;
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const networkListener = networkConnectionListener(handleConnectionChange);
|
||||
return () => networkListener.removeEventListener();
|
||||
|
|
@ -168,7 +170,6 @@ const NetworkIndicator = ({
|
|||
useEffect(() => {
|
||||
const handleAppStateChange = stateChange(async (appState: AppStateStatus) => {
|
||||
const active = appState === 'active';
|
||||
|
||||
handleWebSocket(active);
|
||||
|
||||
if (active) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue