From b03c28529095cd1c8d092f75ef87fad65fe3d9a6 Mon Sep 17 00:00:00 2001 From: tienifr Date: Wed, 14 Jun 2023 11:30:27 +0700 Subject: [PATCH 1/3] fix: 20412 new user is not navigating to concierge chat after tab on link --- src/libs/SidebarUtils.js | 23 +++++++++++++++++++++++ src/libs/actions/Report.js | 3 ++- src/pages/home/sidebar/SidebarLinks.js | 5 +++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/libs/SidebarUtils.js b/src/libs/SidebarUtils.js index 87e8b97d0bd0..7005c6594772 100644 --- a/src/libs/SidebarUtils.js +++ b/src/libs/SidebarUtils.js @@ -90,6 +90,26 @@ Onyx.connect({ callback: (val) => (preferredLocale = val || CONST.LOCALES.DEFAULT), }); +let resolveSidebarIsReadyPromise; + +let sidebarIsReadyPromise = new Promise((resolve) => { + resolveSidebarIsReadyPromise = resolve; +}); + +function resetIsSidebarLoadedReadyPromise() { + sidebarIsReadyPromise = new Promise((resolve) => { + resolveSidebarIsReadyPromise = resolve; + }); +} + +function isSidebarLoadedReady() { + return sidebarIsReadyPromise; +} + +function setIsSidebarLoadedReady() { + resolveSidebarIsReadyPromise(); +} + /** * @param {String} reportIDFromRoute * @returns {String[]} An array of reportIDs sorted in the proper order @@ -349,4 +369,7 @@ function getOptionData(reportID) { export default { getOptionData, getOrderedReportIDs, + setIsSidebarLoadedReady, + isSidebarLoadedReady, + resetIsSidebarLoadedReadyPromise, }; diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index f459b7746ce8..1f7e9f00044f 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -23,6 +23,7 @@ import * as CollectionUtils from '../CollectionUtils'; import * as EmojiUtils from '../EmojiUtils'; import * as ErrorUtils from '../ErrorUtils'; import * as Welcome from './Welcome'; +import SidebarUtils from '../SidebarUtils'; let currentUserEmail; let currentUserAccountID; @@ -1638,7 +1639,7 @@ function openReportFromDeepLink(url, isAuthenticated) { // Navigate to the report after sign-in/sign-up. InteractionManager.runAfterInteractions(() => { - Navigation.isReportScreenReady().then(() => { + SidebarUtils.isSidebarLoadedReady().then(() => { if (reportID) { Navigation.navigate(ROUTES.getReportRoute(reportID)); } diff --git a/src/pages/home/sidebar/SidebarLinks.js b/src/pages/home/sidebar/SidebarLinks.js index a072402a4ca3..9b502193d704 100644 --- a/src/pages/home/sidebar/SidebarLinks.js +++ b/src/pages/home/sidebar/SidebarLinks.js @@ -110,9 +110,14 @@ class SidebarLinks extends React.Component { componentDidMount() { App.setSidebarLoaded(); + SidebarUtils.setIsSidebarLoadedReady(); this.isSidebarLoaded = true; } + componentWillUnmount() { + SidebarUtils.resetIsSidebarLoadedReadyPromise(); + } + showSearchPage() { if (this.props.isCreateMenuOpen) { // Prevent opening Search page when click Search icon quickly after clicking FAB icon From ae34f8aae182875f6ff04deb3a655f1b947d30cd Mon Sep 17 00:00:00 2001 From: tienifr Date: Wed, 14 Jun 2023 23:32:42 +0700 Subject: [PATCH 2/3] remove unused code --- src/libs/Navigation/Navigation.js | 22 ---------------------- src/pages/home/ReportScreen.js | 6 +++--- 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/src/libs/Navigation/Navigation.js b/src/libs/Navigation/Navigation.js index d61eb7143de0..952faaf9a6b7 100644 --- a/src/libs/Navigation/Navigation.js +++ b/src/libs/Navigation/Navigation.js @@ -17,11 +17,6 @@ const navigationIsReadyPromise = new Promise((resolve) => { resolveNavigationIsReadyPromise = resolve; }); -let resolveReportScreenIsReadyPromise; -let reportScreenIsReadyPromise = new Promise((resolve) => { - resolveReportScreenIsReadyPromise = resolve; -}); - let pendingRoute = null; /** @@ -219,20 +214,6 @@ function setIsNavigationReady() { resolveNavigationIsReadyPromise(); } -function resetIsReportScreenReadyPromise() { - reportScreenIsReadyPromise = new Promise((resolve) => { - resolveReportScreenIsReadyPromise = resolve; - }); -} - -function isReportScreenReady() { - return reportScreenIsReadyPromise; -} - -function setIsReportScreenIsReady() { - resolveReportScreenIsReadyPromise(); -} - export default { canNavigate, navigate, @@ -244,9 +225,6 @@ export default { isNavigationReady, setIsNavigationReady, getReportIDFromRoute, - resetIsReportScreenReadyPromise, - isReportScreenReady, - setIsReportScreenIsReady, getTopmostReportId, }; diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 652ea5eb5d2c..d93314641fef 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -168,10 +168,10 @@ class ReportScreen extends React.Component { } componentWillUnmount() { - if (this.unsubscribeVisibilityListener) { - this.unsubscribeVisibilityListener(); + if (!this.unsubscribeVisibilityListener) { + return; } - Navigation.resetIsReportScreenReadyPromise(); + this.unsubscribeVisibilityListener(); } /** From 5e7a8e92a5b6551d844b8316347df9010dc31124 Mon Sep 17 00:00:00 2001 From: tienifr Date: Thu, 15 Jun 2023 09:35:49 +0700 Subject: [PATCH 3/3] fix: remove setIsReportScreenIsReady --- src/pages/home/ReportScreen.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index d93314641fef..c18116ce5635 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -149,7 +149,6 @@ class ReportScreen extends React.Component { this.fetchReportIfNeeded(); ComposerActions.setShouldShowComposeInput(true); - Navigation.setIsReportScreenIsReady(); } componentDidUpdate(prevProps) {