@@ -86,12 +86,14 @@ type ActionSubscriber = {
86
86
callback : SubscriberCallback ;
87
87
} ;
88
88
89
+ let conciergeChatReportID : string | undefined ;
89
90
let currentUserAccountID = - 1 ;
90
91
Onyx . connect ( {
91
92
key : ONYXKEYS . SESSION ,
92
93
callback : ( value ) => {
93
94
// When signed out, val is undefined
94
95
if ( ! value ?. accountID ) {
96
+ conciergeChatReportID = undefined ;
95
97
return ;
96
98
}
97
99
@@ -168,7 +170,6 @@ Onyx.connect({
168
170
} ) ;
169
171
170
172
const allReports : OnyxCollection < Report > = { } ;
171
- let conciergeChatReportID : string | undefined ;
172
173
const typingWatchTimers : Record < string , NodeJS . Timeout > = { } ;
173
174
174
175
let reportIDDeeplinkedFromOldDot : string | undefined ;
@@ -1716,24 +1717,29 @@ function updateWriteCapabilityAndNavigate(report: Report, newValue: WriteCapabil
1716
1717
1717
1718
/**
1718
1719
* Navigates to the 1:1 report with Concierge
1719
- *
1720
- * @param ignoreConciergeReportID - Flag to ignore conciergeChatReportID during navigation. The default behavior is to not ignore.
1721
1720
*/
1722
- function navigateToConciergeChat ( ignoreConciergeReportID = false , shouldDismissModal = false ) {
1721
+ function navigateToConciergeChat ( shouldDismissModal = false , shouldPopCurrentScreen = false , checkIfCurrentPageActive = ( ) => true ) {
1723
1722
// If conciergeChatReportID contains a concierge report ID, we navigate to the concierge chat using the stored report ID.
1724
1723
// Otherwise, we would find the concierge chat and navigate to it.
1725
- // Now, when user performs sign-out and a sign-in again, conciergeChatReportID may contain a stale value.
1726
- // In order to prevent navigation to a stale value, we use ignoreConciergeReportID to forcefully find and navigate to concierge chat.
1727
- if ( ! conciergeChatReportID || ignoreConciergeReportID ) {
1724
+ if ( ! conciergeChatReportID ) {
1728
1725
// In order to avoid creating concierge repeatedly,
1729
1726
// we need to ensure that the server data has been successfully pulled
1730
1727
Welcome . serverDataIsReadyPromise ( ) . then ( ( ) => {
1731
1728
// If we don't have a chat with Concierge then create it
1729
+ if ( ! checkIfCurrentPageActive ( ) ) {
1730
+ return ;
1731
+ }
1732
+ if ( shouldPopCurrentScreen && ! shouldDismissModal ) {
1733
+ Navigation . goBack ( ) ;
1734
+ }
1732
1735
navigateToAndOpenReport ( [ CONST . EMAIL . CONCIERGE ] , shouldDismissModal ) ;
1733
1736
} ) ;
1734
1737
} else if ( shouldDismissModal ) {
1735
1738
Navigation . dismissModal ( conciergeChatReportID ) ;
1736
1739
} else {
1740
+ if ( shouldPopCurrentScreen ) {
1741
+ Navigation . goBack ( ) ;
1742
+ }
1737
1743
Navigation . navigate ( ROUTES . REPORT_WITH_ID . getRoute ( conciergeChatReportID ) ) ;
1738
1744
}
1739
1745
}
@@ -2213,10 +2219,7 @@ function openReportFromDeepLink(url: string, isAuthenticated: boolean) {
2213
2219
Session . waitForUserSignIn ( ) . then ( ( ) => {
2214
2220
Navigation . waitForProtectedRoutes ( ) . then ( ( ) => {
2215
2221
const route = ReportUtils . getRouteFromLink ( url ) ;
2216
- if ( route === ROUTES . CONCIERGE ) {
2217
- navigateToConciergeChat ( true ) ;
2218
- return ;
2219
- }
2222
+
2220
2223
if ( route && Session . isAnonymousUser ( ) && ! Session . canAccessRouteByAnonymousUser ( route ) ) {
2221
2224
Session . signOutAndRedirectToSignIn ( true ) ;
2222
2225
return ;
0 commit comments