From e990f51af66125cb785bafa850a04778f4152bed Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Wed, 8 Oct 2025 16:26:13 +0700 Subject: [PATCH 1/3] remove connect method --- .../Navigation/AppNavigator/AuthScreens.tsx | 47 ++++++++----------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index 0fee45ceb335..dfc1b1b6b882 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -1,7 +1,7 @@ import type {RouteProp} from '@react-navigation/native'; import {useNavigation} from '@react-navigation/native'; import type {StackCardInterpolationProps} from '@react-navigation/stack'; -import React, {memo, useContext, useEffect, useMemo, useState} from 'react'; +import React, {memo, useContext, useEffect, useMemo, useRef, useState} from 'react'; import type {OnyxEntry} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import ComposeProviders from '@components/ComposeProviders'; @@ -105,32 +105,6 @@ function initializePusher() { }).then(() => { User.subscribeToUserEvents(); }); -} -let lastUpdateIDAppliedToClient: OnyxEntry; -let isLoadingApp = false; - -Onyx.connect({ - key: ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT, - callback: (value) => { - lastUpdateIDAppliedToClient = value; - }, -}); - -Onyx.connect({ - key: ONYXKEYS.IS_LOADING_APP, - callback: (value) => { - isLoadingApp = !!value; - }, -}); - -function handleNetworkReconnect() { - if (isLoadingApp) { - App.openApp(); - } else { - Log.info('[handleNetworkReconnect] Sending ReconnectApp'); - App.reconnectApp(lastUpdateIDAppliedToClient); - } -} const RootStack = createRootStackNavigator(); @@ -199,6 +173,25 @@ function AuthScreens() { const [initialLastUpdateIDAppliedToClient] = useOnyx(ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT, {canBeMissing: true}); const [modal] = useOnyx(ONYXKEYS.MODAL, {canBeMissing: true}); + const [lastUpdateIDAppliedToClient] = useOnyx(ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT, {canBeMissing: true}); + const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true}); + const lastUpdateIDAppliedToClientRef = useRef(lastUpdateIDAppliedToClient); + const isLoadingAppRef = useRef(isLoadingApp); + + // eslint-disable-next-line react-compiler/react-compiler + lastUpdateIDAppliedToClientRef.current = lastUpdateIDAppliedToClient; + isLoadingAppRef.current = isLoadingApp; + + + const handleNetworkReconnect = () => { + if (isLoadingAppRef.current) { + App.openApp(); + } else { + Log.info('[handleNetworkReconnect] Sending ReconnectApp'); + App.reconnectApp(lastUpdateIDAppliedToClientRef.current); + } + }; + // On HybridApp we need to prevent flickering during transition to OldDot const shouldRenderOnboardingExclusivelyOnHybridApp = useMemo(() => { return CONFIG.IS_HYBRID_APP && Navigation.getActiveRoute().includes(ROUTES.ONBOARDING_INTERESTED_FEATURES.route) && isOnboardingCompleted === true; From c47ba515035d0403c6f4782f0fc42499086a91c7 Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Wed, 8 Oct 2025 16:41:25 +0700 Subject: [PATCH 2/3] chore --- src/libs/Navigation/AppNavigator/AuthScreens.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index dfc1b1b6b882..14d5862682d4 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -2,8 +2,6 @@ import type {RouteProp} from '@react-navigation/native'; import {useNavigation} from '@react-navigation/native'; import type {StackCardInterpolationProps} from '@react-navigation/stack'; import React, {memo, useContext, useEffect, useMemo, useRef, useState} from 'react'; -import type {OnyxEntry} from 'react-native-onyx'; -import Onyx from 'react-native-onyx'; import ComposeProviders from '@components/ComposeProviders'; import DelegateNoAccessModalProvider from '@components/DelegateNoAccessModalProvider'; import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; @@ -105,6 +103,7 @@ function initializePusher() { }).then(() => { User.subscribeToUserEvents(); }); +} const RootStack = createRootStackNavigator(); @@ -180,9 +179,9 @@ function AuthScreens() { // eslint-disable-next-line react-compiler/react-compiler lastUpdateIDAppliedToClientRef.current = lastUpdateIDAppliedToClient; + // eslint-disable-next-line react-compiler/react-compiler isLoadingAppRef.current = isLoadingApp; - const handleNetworkReconnect = () => { if (isLoadingAppRef.current) { App.openApp(); From d65ed98a4da19151cedc35bfc068f6ee57a76473 Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Wed, 8 Oct 2025 16:47:03 +0700 Subject: [PATCH 3/3] chore --- src/libs/Navigation/AppNavigator/AuthScreens.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index 14d5862682d4..89dc6f5b5ee2 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -176,7 +176,6 @@ function AuthScreens() { const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true}); const lastUpdateIDAppliedToClientRef = useRef(lastUpdateIDAppliedToClient); const isLoadingAppRef = useRef(isLoadingApp); - // eslint-disable-next-line react-compiler/react-compiler lastUpdateIDAppliedToClientRef.current = lastUpdateIDAppliedToClient; // eslint-disable-next-line react-compiler/react-compiler