Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dl desktop error fix #29688

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 15 additions & 20 deletions src/libs/Navigation/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,34 +286,29 @@ function navContainsProtectedRoutes(state) {
*
* @function
* @returns {Promise<void>} A promise that resolves to `true` when the Concierge route is present.
* Rejects with an error if the navigation is not ready.
*
* @example
* waitForProtectedRoutes()
* .then(() => console.log('Protected routes are present!'))
* .catch(error => console.error(error.message));
*/
function waitForProtectedRoutes() {
return new Promise((resolve, reject) => {
const isReady = navigationRef.current && navigationRef.current.isReady();
if (!isReady) {
reject(new Error('[Navigation] is not ready yet!'));
return;
}
const currentState = navigationRef.current.getState();
if (navContainsProtectedRoutes(currentState)) {
resolve();
return;
}
let unsubscribe;
const handleStateChange = ({data}) => {
const state = lodashGet(data, 'state');
if (navContainsProtectedRoutes(state)) {
unsubscribe();
return new Promise((resolve) => {
isNavigationReady().then(() => {
const currentState = navigationRef.current.getState();
if (navContainsProtectedRoutes(currentState)) {
resolve();
return;
}
};
unsubscribe = navigationRef.current.addListener('state', handleStateChange);
let unsubscribe;
const handleStateChange = ({data}) => {
const state = lodashGet(data, 'state');
if (navContainsProtectedRoutes(state)) {
unsubscribe();
resolve();
}
};
unsubscribe = navigationRef.current.addListener('state', handleStateChange);
});
});
}

Expand Down
19 changes: 8 additions & 11 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -1903,20 +1903,17 @@ function openReportFromDeepLink(url, isAuthenticated) {
// If we're not opening a public room (no reportID) or the user is authenticated, we unblock the UI (hide splash screen)
Onyx.set(ONYXKEYS.IS_CHECKING_PUBLIC_ROOM, false);
}

// Navigate to the report after sign-in/sign-up.
InteractionManager.runAfterInteractions(() => {
Session.waitForUserSignIn().then(() => {
Navigation.waitForProtectedRoutes()
.then(() => {
const route = ReportUtils.getRouteFromLink(url);
if (route === ROUTES.CONCIERGE) {
navigateToConciergeChat(true);
return;
}
Navigation.navigate(route, CONST.NAVIGATION.TYPE.PUSH);
})
.catch((error) => Log.warn(error.message));
Navigation.waitForProtectedRoutes().then(() => {
const route = ReportUtils.getRouteFromLink(url);
if (route === ROUTES.CONCIERGE) {
navigateToConciergeChat(true);
return;
}
Navigation.navigate(route, CONST.NAVIGATION.TYPE.PUSH);
});
});
});
}
Expand Down
Loading