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

Not show prompt open in desktop app for magic link #32945

Merged
merged 2 commits into from
Dec 12, 2023
Merged
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
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
Loading