Skip to content

Commit

Permalink
Merge pull request Expensify#37664 from dukenv0307/fix/36811-user-is-…
Browse files Browse the repository at this point in the history
…not-redirected-to-public-room

fix public room is not opened
  • Loading branch information
stitesExpensify authored Mar 12, 2024
2 parents 33f707e + 8b7e63b commit 6641ca0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Expensify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@ function Expensify({
// If the app is opened from a deep link, get the reportID (if exists) from the deep link and navigate to the chat report
Linking.getInitialURL().then((url) => {
setInitialUrl(url);
Report.openReportFromDeepLink(url ?? '', isAuthenticated);
Report.openReportFromDeepLink(url ?? '');
});

// Open chat report from a deep link (only mobile native)
Linking.addEventListener('url', (state) => {
Report.openReportFromDeepLink(state.url, isAuthenticated);
Report.openReportFromDeepLink(state.url);
});

return () => {
Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2229,10 +2229,10 @@ function toggleEmojiReaction(
addEmojiReaction(originalReportID, reportAction.reportActionID, emoji, skinTone);
}

function openReportFromDeepLink(url: string, isAuthenticated: boolean) {
function openReportFromDeepLink(url: string) {
const reportID = ReportUtils.getReportIDFromLink(url);

if (reportID && !isAuthenticated) {
if (reportID && !Session.hasAuthToken()) {
// Call the OpenReport command to check in the server if it's a public room. If so, we'll open it as an anonymous user
openReport(reportID, [], {}, '0', true);

Expand Down
8 changes: 8 additions & 0 deletions src/libs/actions/Session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ function hasStashedSession(): boolean {
return Boolean(stashedSession.authToken && stashedCredentials.autoGeneratedLogin && stashedCredentials.autoGeneratedLogin !== '');
}

/**
* Checks if the user has authToken
*/
function hasAuthToken(): boolean {
return !!session.authToken;
}

function signOutAndRedirectToSignIn(shouldReplaceCurrentScreen?: boolean, shouldStashSession?: boolean) {
Log.info('Redirecting to Sign In because signOut() was called');
hideContextMenu(false);
Expand Down Expand Up @@ -987,6 +994,7 @@ export {
toggleTwoFactorAuth,
validateTwoFactorAuth,
waitForUserSignIn,
hasAuthToken,
canAnonymousUserAccessRoute,
signInWithSupportAuthToken,
isSupportAuthToken,
Expand Down

0 comments on commit 6641ca0

Please sign in to comment.