From 374406d39734613916af3d883776fe531d194059 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Tue, 9 Apr 2024 16:53:11 -0700 Subject: [PATCH 1/5] fix: check if the OpenApp has finished or not before updating Onyx data --- src/libs/actions/OnyxUpdateManager.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/OnyxUpdateManager.ts b/src/libs/actions/OnyxUpdateManager.ts index cc51cbd22deb..81eb14c3da88 100644 --- a/src/libs/actions/OnyxUpdateManager.ts +++ b/src/libs/actions/OnyxUpdateManager.ts @@ -28,12 +28,19 @@ Onyx.connect({ callback: (value) => (lastUpdateIDAppliedToClient = value), }); +let isLoadingApp: boolean | null = false; +Onyx.connect({ + key: ONYXKEYS.IS_LOADING_APP, + callback: (value) => (isLoadingApp = value), +}); + export default () => { console.debug('[OnyxUpdateManager] Listening for updates from the server'); Onyx.connect({ key: ONYXKEYS.ONYX_UPDATES_FROM_SERVER, callback: (value) => { - if (!value) { + // When the OpenApp command hasn't finished yet, we should not process any updates. + if (!value || isLoadingApp) { return; } // This key is shared across clients, thus every client/tab will have a copy and try to execute this method. From ccbbe130e629ac129af3ae1ccc90cc090cae9caa Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Tue, 9 Apr 2024 16:56:42 -0700 Subject: [PATCH 2/5] fix: use false when the value is null --- src/libs/actions/OnyxUpdateManager.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/OnyxUpdateManager.ts b/src/libs/actions/OnyxUpdateManager.ts index 81eb14c3da88..fef942a5323c 100644 --- a/src/libs/actions/OnyxUpdateManager.ts +++ b/src/libs/actions/OnyxUpdateManager.ts @@ -31,7 +31,9 @@ Onyx.connect({ let isLoadingApp: boolean | null = false; Onyx.connect({ key: ONYXKEYS.IS_LOADING_APP, - callback: (value) => (isLoadingApp = value), + callback: (value) => { + isLoadingApp = value ?? false; + }, }); export default () => { From 6392d49e126d97cc3c07c4fa1eb08fa664d89863 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Tue, 9 Apr 2024 17:32:09 -0700 Subject: [PATCH 3/5] fix: remove null from the type declaration --- src/libs/actions/OnyxUpdateManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/OnyxUpdateManager.ts b/src/libs/actions/OnyxUpdateManager.ts index fef942a5323c..36058a7cb492 100644 --- a/src/libs/actions/OnyxUpdateManager.ts +++ b/src/libs/actions/OnyxUpdateManager.ts @@ -28,7 +28,7 @@ Onyx.connect({ callback: (value) => (lastUpdateIDAppliedToClient = value), }); -let isLoadingApp: boolean | null = false; +let isLoadingApp = false; Onyx.connect({ key: ONYXKEYS.IS_LOADING_APP, callback: (value) => { From fe9f6b2434a5bd29092e6f74e60ac3142fd38de3 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Tue, 9 Apr 2024 17:35:16 -0700 Subject: [PATCH 4/5] chore: add log statement --- src/libs/actions/OnyxUpdateManager.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/actions/OnyxUpdateManager.ts b/src/libs/actions/OnyxUpdateManager.ts index 36058a7cb492..56c3552dfd00 100644 --- a/src/libs/actions/OnyxUpdateManager.ts +++ b/src/libs/actions/OnyxUpdateManager.ts @@ -43,6 +43,7 @@ export default () => { callback: (value) => { // When the OpenApp command hasn't finished yet, we should not process any updates. if (!value || isLoadingApp) { + console.debug(`[OnyxUpdateManager] Ignoring Onyx updates while OpenApp hans't finished yet.`); return; } // This key is shared across clients, thus every client/tab will have a copy and try to execute this method. From ac9b108ec7d9102629227dea847238b81b535200 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Tue, 9 Apr 2024 23:14:38 -0700 Subject: [PATCH 5/5] fix: condition to log the info --- src/libs/actions/OnyxUpdateManager.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/OnyxUpdateManager.ts b/src/libs/actions/OnyxUpdateManager.ts index 56c3552dfd00..40f522e215b5 100644 --- a/src/libs/actions/OnyxUpdateManager.ts +++ b/src/libs/actions/OnyxUpdateManager.ts @@ -43,7 +43,9 @@ export default () => { callback: (value) => { // When the OpenApp command hasn't finished yet, we should not process any updates. if (!value || isLoadingApp) { - console.debug(`[OnyxUpdateManager] Ignoring Onyx updates while OpenApp hans't finished yet.`); + if (isLoadingApp) { + console.debug(`[OnyxUpdateManager] Ignoring Onyx updates while OpenApp hans't finished yet.`); + } return; } // This key is shared across clients, thus every client/tab will have a copy and try to execute this method.