From dab847b7b5bb090be5e2436e6e6581740eee1a8a Mon Sep 17 00:00:00 2001 From: hublot Date: Fri, 19 May 2023 23:06:15 +0800 Subject: [PATCH 1/5] Add Welcome.isReadyPromise in navigateToConciergeChat --- src/libs/actions/Report.js | 17 +++++++++++------ src/libs/actions/Welcome.js | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 6a4cd9fe3050..58ccbff4bbb9 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -22,6 +22,7 @@ import * as OptionsListUtils from '../OptionsListUtils'; import * as Localize from '../Localize'; import * as CollectionUtils from '../CollectionUtils'; import * as EmojiUtils from '../EmojiUtils'; +import * as Welcome from './Welcome' let currentUserEmail; let currentUserAccountID; @@ -1122,13 +1123,17 @@ function updateNotificationPreferenceAndNavigate(reportID, previousValue, newVal * Navigates to the 1:1 report with Concierge */ function navigateToConciergeChat() { - // If we don't have a chat with Concierge then create it - if (!conciergeChatReportID) { - navigateToAndOpenReport([CONST.EMAIL.CONCIERGE]); - return; - } + // In order to avoid creating concierge repeatedly, + // we need to ensure that the server data has been successfully pulled + Welcome.isReadyPromise.then(() => { + // If we don't have a chat with Concierge then create it + if (!conciergeChatReportID) { + navigateToAndOpenReport([CONST.EMAIL.CONCIERGE]); + return; + } - Navigation.navigate(ROUTES.getReportRoute(conciergeChatReportID)); + Navigation.navigate(ROUTES.getReportRoute(conciergeChatReportID)); + }) } /** diff --git a/src/libs/actions/Welcome.js b/src/libs/actions/Welcome.js index c3e8599a0169..016287d8a789 100644 --- a/src/libs/actions/Welcome.js +++ b/src/libs/actions/Welcome.js @@ -151,4 +151,4 @@ function resetReadyCheck() { }); } -export {show, resetReadyCheck}; +export {show, isReadyPromise, resetReadyCheck}; From 4960191f26d82ff90c3025b78918875773f001b4 Mon Sep 17 00:00:00 2001 From: hublot Date: Fri, 19 May 2023 23:37:13 +0800 Subject: [PATCH 2/5] Fix Lint --- src/libs/actions/Report.js | 4 ++-- src/libs/actions/Welcome.js | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 58ccbff4bbb9..c4c79cf19d92 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1125,7 +1125,7 @@ function updateNotificationPreferenceAndNavigate(reportID, previousValue, newVal function navigateToConciergeChat() { // In order to avoid creating concierge repeatedly, // we need to ensure that the server data has been successfully pulled - Welcome.isReadyPromise.then(() => { + Welcome.serverDataIsReadyPromise().then(() => { // If we don't have a chat with Concierge then create it if (!conciergeChatReportID) { navigateToAndOpenReport([CONST.EMAIL.CONCIERGE]); @@ -1133,7 +1133,7 @@ function navigateToConciergeChat() { } Navigation.navigate(ROUTES.getReportRoute(conciergeChatReportID)); - }) + }); } /** diff --git a/src/libs/actions/Welcome.js b/src/libs/actions/Welcome.js index 016287d8a789..ddd0d872ce97 100644 --- a/src/libs/actions/Welcome.js +++ b/src/libs/actions/Welcome.js @@ -151,4 +151,8 @@ function resetReadyCheck() { }); } -export {show, isReadyPromise, resetReadyCheck}; +function serverDataIsReadyPromise() { + return isReadyPromise; +} + +export {show, serverDataIsReadyPromise, resetReadyCheck}; From 1a4f70af3ff134293ae686c02c0d3b5eb87a407e Mon Sep 17 00:00:00 2001 From: hublot Date: Fri, 19 May 2023 23:46:10 +0800 Subject: [PATCH 3/5] Fix Prettier --- src/libs/actions/Report.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index c4c79cf19d92..706bfaed7135 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -22,7 +22,7 @@ import * as OptionsListUtils from '../OptionsListUtils'; import * as Localize from '../Localize'; import * as CollectionUtils from '../CollectionUtils'; import * as EmojiUtils from '../EmojiUtils'; -import * as Welcome from './Welcome' +import * as Welcome from './Welcome'; let currentUserEmail; let currentUserAccountID; @@ -1123,7 +1123,7 @@ function updateNotificationPreferenceAndNavigate(reportID, previousValue, newVal * Navigates to the 1:1 report with Concierge */ function navigateToConciergeChat() { - // In order to avoid creating concierge repeatedly, + // In order to avoid creating concierge repeatedly, // we need to ensure that the server data has been successfully pulled Welcome.serverDataIsReadyPromise().then(() => { // If we don't have a chat with Concierge then create it From 034ff4a0a8b4b8ef9be100dc489e10c41ca0d68a Mon Sep 17 00:00:00 2001 From: hublot Date: Tue, 23 May 2023 23:37:34 +0800 Subject: [PATCH 4/5] Keep the report screen life cycle --- src/libs/actions/Report.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 706bfaed7135..c84d5dad9007 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1123,17 +1123,19 @@ function updateNotificationPreferenceAndNavigate(reportID, previousValue, newVal * Navigates to the 1:1 report with Concierge */ function navigateToConciergeChat() { - // In order to avoid creating concierge repeatedly, - // we need to ensure that the server data has been successfully pulled - Welcome.serverDataIsReadyPromise().then(() => { - // If we don't have a chat with Concierge then create it - if (!conciergeChatReportID) { - navigateToAndOpenReport([CONST.EMAIL.CONCIERGE]); - return; + if (!conciergeChatReportID) { + // In order not to delay the report life cycle, we first navigate to the unknow report + if (Navigation.getReportIDFromRoute().length <= 0) { + Navigation.navigate(ROUTES.REPORT); } - + // In order to avoid creating concierge repeatedly, + // we need to ensure that the server data has been successfully pulled + Welcome.serverDataIsReadyPromise().then(() => { + navigateToAndOpenReport([CONST.EMAIL.CONCIERGE]); + }); + } else { Navigation.navigate(ROUTES.getReportRoute(conciergeChatReportID)); - }); + } } /** From 5de3771615646fa3105458c0077decf239fb5703 Mon Sep 17 00:00:00 2001 From: hublot Date: Wed, 24 May 2023 19:04:39 +0800 Subject: [PATCH 5/5] Fix typo and change getReportIDFromRoute condition --- src/libs/actions/Report.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 99e8dc6d4dc5..a67ae9343b71 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1127,13 +1127,14 @@ function updateWriteCapabilityAndNavigate(report, newValue) { */ function navigateToConciergeChat() { if (!conciergeChatReportID) { - // In order not to delay the report life cycle, we first navigate to the unknow report - if (Navigation.getReportIDFromRoute().length <= 0) { + // In order not to delay the report life cycle, we first navigate to the unknown report + if (_.isEmpty(Navigation.getReportIDFromRoute())) { Navigation.navigate(ROUTES.REPORT); } // In order to avoid creating concierge repeatedly, // we need to ensure that the server data has been successfully pulled Welcome.serverDataIsReadyPromise().then(() => { + // If we don't have a chat with Concierge then create it navigateToAndOpenReport([CONST.EMAIL.CONCIERGE]); }); } else {