From c8cefa268b4fa77fe4018c8fdfe646420cccbada Mon Sep 17 00:00:00 2001 From: Github Date: Mon, 2 Sep 2024 12:58:58 +0200 Subject: [PATCH 1/2] fix Pusher instance not found error --- src/libs/Navigation/AppNavigator/AuthScreens.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index de9aeb2e29fc..b10912ebccad 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -107,6 +107,16 @@ function getCentralPaneScreenInitialParams(screenName: CentralPaneName, initialR return undefined; } +function initializePusher() { + Pusher.init({ + appKey: CONFIG.PUSHER.APP_KEY, + cluster: CONFIG.PUSHER.CLUSTER, + authEndpoint: `${CONFIG.EXPENSIFY.DEFAULT_API_ROOT}api/AuthenticatePusher?`, + }).then(() => { + User.subscribeToUserEvents(); + }); +} + let timezone: Timezone | null; let currentAccountID = -1; let isLoadingApp = false; @@ -125,7 +135,7 @@ Onyx.connect({ if (Navigation.isActiveRoute(ROUTES.SIGN_IN_MODAL)) { // This means sign in in RHP was successful, so we can subscribe to user events - User.subscribeToUserEvents(); + initializePusher(); } }, }); @@ -261,7 +271,7 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie cluster: CONFIG.PUSHER.CLUSTER, authEndpoint: `${CONFIG.EXPENSIFY.DEFAULT_API_ROOT}api/AuthenticatePusher?`, }).then(() => { - User.subscribeToUserEvents(); + initializePusher(); }); // If we are on this screen then we are "logged in", but the user might not have "just logged in". They could be reopening the app From 326aa51f1d1e19e0b06029108a59c6162bd05689 Mon Sep 17 00:00:00 2001 From: Github Date: Tue, 3 Sep 2024 12:03:12 +0200 Subject: [PATCH 2/2] small fix --- src/libs/Navigation/AppNavigator/AuthScreens.tsx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index b10912ebccad..96f4ae185b2c 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -266,13 +266,7 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie NetworkConnection.listenForReconnect(); NetworkConnection.onReconnect(handleNetworkReconnect); PusherConnectionManager.init(); - Pusher.init({ - appKey: CONFIG.PUSHER.APP_KEY, - cluster: CONFIG.PUSHER.CLUSTER, - authEndpoint: `${CONFIG.EXPENSIFY.DEFAULT_API_ROOT}api/AuthenticatePusher?`, - }).then(() => { - initializePusher(); - }); + initializePusher(); // If we are on this screen then we are "logged in", but the user might not have "just logged in". They could be reopening the app // or returning from background. If so, we'll assume they have some app data already and we can call reconnectApp() instead of openApp().