Skip to content

Commit

Permalink
Merge pull request #20740 from tienifr/fix/20412
Browse files Browse the repository at this point in the history
fix: 20412 new user is not navigating to concierge chat after tab on link
  • Loading branch information
mountiny authored Jun 15, 2023
2 parents 4c1739b + 5e7a8e9 commit 9ed4a16
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 27 deletions.
22 changes: 0 additions & 22 deletions src/libs/Navigation/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ const navigationIsReadyPromise = new Promise((resolve) => {
resolveNavigationIsReadyPromise = resolve;
});

let resolveReportScreenIsReadyPromise;
let reportScreenIsReadyPromise = new Promise((resolve) => {
resolveReportScreenIsReadyPromise = resolve;
});

let pendingRoute = null;

/**
Expand Down Expand Up @@ -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,
Expand All @@ -244,9 +225,6 @@ export default {
isNavigationReady,
setIsNavigationReady,
getReportIDFromRoute,
resetIsReportScreenReadyPromise,
isReportScreenReady,
setIsReportScreenIsReady,
getTopmostReportId,
};

Expand Down
23 changes: 23 additions & 0 deletions src/libs/SidebarUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -354,4 +374,7 @@ function getOptionData(reportID) {
export default {
getOptionData,
getOrderedReportIDs,
setIsSidebarLoadedReady,
isSidebarLoadedReady,
resetIsSidebarLoadedReadyPromise,
};
3 changes: 2 additions & 1 deletion src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1593,7 +1594,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));
}
Expand Down
7 changes: 3 additions & 4 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ class ReportScreen extends React.Component {

this.fetchReportIfNeeded();
ComposerActions.setShouldShowComposeInput(true);
Navigation.setIsReportScreenIsReady();
}

componentDidUpdate(prevProps) {
Expand All @@ -168,10 +167,10 @@ class ReportScreen extends React.Component {
}

componentWillUnmount() {
if (this.unsubscribeVisibilityListener) {
this.unsubscribeVisibilityListener();
if (!this.unsubscribeVisibilityListener) {
return;
}
Navigation.resetIsReportScreenReadyPromise();
this.unsubscribeVisibilityListener();
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/pages/home/sidebar/SidebarLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9ed4a16

Please sign in to comment.