Skip to content

Commit

Permalink
Merge pull request #19294 from hellohublot/Fix_Duplicate_Concierge_Cr…
Browse files Browse the repository at this point in the history
…eated

Fix duplicate concierge report was created
  • Loading branch information
mountiny authored May 24, 2023
2 parents 36102d1 + 5de3771 commit b10f19d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
18 changes: 13 additions & 5 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import * as OptionsListUtils from '../OptionsListUtils';
import * as CollectionUtils from '../CollectionUtils';
import * as EmojiUtils from '../EmojiUtils';
import * as ErrorUtils from '../ErrorUtils';
import * as Welcome from './Welcome';

let currentUserEmail;
let currentUserAccountID;
Expand Down Expand Up @@ -1125,13 +1126,20 @@ function updateWriteCapabilityAndNavigate(report, newValue) {
* 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 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 {
Navigation.navigate(ROUTES.getReportRoute(conciergeChatReportID));
}

Navigation.navigate(ROUTES.getReportRoute(conciergeChatReportID));
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/libs/actions/Welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,8 @@ function resetReadyCheck() {
});
}

export {show, resetReadyCheck};
function serverDataIsReadyPromise() {
return isReadyPromise;
}

export {show, serverDataIsReadyPromise, resetReadyCheck};

0 comments on commit b10f19d

Please sign in to comment.