From 6aa1dcfa038d73c58d6009ea94293d4dafd61e26 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 22 Aug 2024 09:33:06 +0800 Subject: [PATCH 1/2] disconnect from onboarding onyx once navigated to the deep link --- src/libs/actions/Report.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 7eb7e01d6edd..967e17b85e8d 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -2674,7 +2674,7 @@ function openReportFromDeepLink(url: string) { // Navigate to the report after sign-in/sign-up. InteractionManager.runAfterInteractions(() => { Session.waitForUserSignIn().then(() => { - Onyx.connect({ + const connectionID = Onyx.connect({ key: ONYXKEYS.NVP_ONBOARDING, callback: (onboarding) => { Navigation.waitForProtectedRoutes().then(() => { @@ -2713,6 +2713,7 @@ function openReportFromDeepLink(url: string) { return; } + Onyx.disconnect(connectionID); Navigation.navigate(route as Route, CONST.NAVIGATION.ACTION_TYPE.PUSH); }); }, From a32c06ba71c5a60640fbb32e64e092ec06abe1cf Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 27 Aug 2024 12:30:15 +0800 Subject: [PATCH 2/2] disconnect it earlier --- src/libs/actions/Report.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index d21e9cd086c2..bc5f7a347cd0 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -2668,9 +2668,15 @@ function openReportFromDeepLink(url: string) { // Navigate to the report after sign-in/sign-up. InteractionManager.runAfterInteractions(() => { Session.waitForUserSignIn().then(() => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.NVP_ONBOARDING, callback: (onboarding) => { + if (onboarding) { + // Once the onboarding data is available, we want to disconnect the connection + // so it won't trigger the deeplink again every time the data is changed, for example, when relogin. + Onyx.disconnect(connection); + } + Navigation.waitForProtectedRoutes().then(() => { if (route && Session.isAnonymousUser() && !Session.canAnonymousUserAccessRoute(route)) { Session.signOutAndRedirectToSignIn(true); @@ -2707,7 +2713,6 @@ function openReportFromDeepLink(url: string) { return; } - Onyx.disconnect(connectionID); Navigation.navigate(route as Route, CONST.NAVIGATION.ACTION_TYPE.PUSH); }); },