Skip to content

Commit

Permalink
wait for protected routes
Browse files Browse the repository at this point in the history
  • Loading branch information
arosiclair committed Nov 21, 2023
1 parent da549c0 commit 475ecff
Showing 1 changed file with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@ export default function subscribeToReportCommentPushNotifications() {
}

Log.info('[PushNotification] onSelected() - called', false, {reportID, reportActionID});
Navigation.isNavigationReady().then(() => {
try {
// If a chat is visible other than the one we are trying to navigate to, then we need to navigate back
if (Navigation.getActiveRoute().slice(1, 2) === ROUTES.REPORT && !Navigation.isActiveRoute(`r/${reportID}`)) {
Navigation.goBack(ROUTES.HOME);
}
Navigation.isNavigationReady()
.then(Navigation.waitForProtectedRoutes)
.then(() => {
try {
// If a chat is visible other than the one we are trying to navigate to, then we need to navigate back
if (Navigation.getActiveRoute().slice(1, 2) === ROUTES.REPORT && !Navigation.isActiveRoute(`r/${reportID}`)) {
Navigation.goBack(ROUTES.HOME);
}

Log.info('[PushNotification] onSelected() - Navigation is ready. Navigating...', false, {reportID, reportActionID});
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(reportID));
} catch (error) {
Log.alert('[PushNotification] onSelected() - failed', {reportID, reportActionID, error: error.message});
}
});
Log.info('[PushNotification] onSelected() - Navigation is ready. Navigating...', false, {reportID, reportActionID});
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(reportID));
} catch (error) {
Log.alert('[PushNotification] onSelected() - failed', {reportID, reportActionID, error: error.message});
}
});
});
}

0 comments on commit 475ecff

Please sign in to comment.