Skip to content

Commit

Permalink
Merge pull request #32945 from dukenv0307/fix/32795
Browse files Browse the repository at this point in the history
Not show prompt open in desktop app for magic link

(cherry picked from commit d376603)
  • Loading branch information
luacmartins authored and OSBotify committed Dec 12, 2023
1 parent 150f95b commit 47354c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/Expensify.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ function Expensify(props) {
}, [props.isCheckingPublicRoom]);

const isAuthenticated = useMemo(() => Boolean(lodashGet(props.session, 'authToken', null)), [props.session]);
const autoAuthState = useMemo(() => lodashGet(props.session, 'autoAuthState', ''), [props.session]);

const contextValue = useMemo(
() => ({
Expand Down Expand Up @@ -207,7 +208,10 @@ function Expensify(props) {
}

return (
<DeeplinkWrapper isAuthenticated={isAuthenticated}>
<DeeplinkWrapper
isAuthenticated={isAuthenticated}
autoAuthState={autoAuthState}
>
{shouldInit && (
<>
<GrowlNotification ref={Growl.growlRef} />
Expand Down
8 changes: 5 additions & 3 deletions src/components/DeeplinkWrapper/index.website.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const propTypes = {
children: PropTypes.node.isRequired,
/** User authentication status */
isAuthenticated: PropTypes.bool.isRequired,
/** The auto authentication status */
autoAuthState: PropTypes.string,
};

function isMacOSWeb() {
Expand All @@ -36,7 +38,7 @@ function promptToOpenInDesktopApp() {
App.beginDeepLinkRedirect(!isMagicLink);
}
}
function DeeplinkWrapper({children, isAuthenticated}) {
function DeeplinkWrapper({children, isAuthenticated, autoAuthState}) {
const [currentScreen, setCurrentScreen] = useState();
const [hasShownPrompt, setHasShownPrompt] = useState(false);
const removeListener = useRef();
Expand Down Expand Up @@ -69,7 +71,7 @@ function DeeplinkWrapper({children, isAuthenticated}) {
return routeRegex.test(window.location.pathname);
});
// Making a few checks to exit early before checking authentication status
if (!isMacOSWeb() || isUnsupportedDeeplinkRoute || CONFIG.ENVIRONMENT === CONST.ENVIRONMENT.DEV || hasShownPrompt) {
if (!isMacOSWeb() || isUnsupportedDeeplinkRoute || hasShownPrompt || CONFIG.ENVIRONMENT === CONST.ENVIRONMENT.DEV || autoAuthState === CONST.AUTO_AUTH_STATE.NOT_STARTED) {
return;
}
// We want to show the prompt immediately if the user is already authenticated.
Expand All @@ -92,7 +94,7 @@ function DeeplinkWrapper({children, isAuthenticated}) {
promptToOpenInDesktopApp();
setHasShownPrompt(true);
}
}, [currentScreen, hasShownPrompt, isAuthenticated]);
}, [currentScreen, hasShownPrompt, isAuthenticated, autoAuthState]);

return children;
}
Expand Down

0 comments on commit 47354c8

Please sign in to comment.