Skip to content

Commit

Permalink
not show promp open in desktop app for magic link
Browse files Browse the repository at this point in the history
  • Loading branch information
dukenv0307 committed Dec 12, 2023
1 parent 776849a commit 69b80bf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/Expensify.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import AppleAuthWrapper from './components/SignInButtons/AppleAuthWrapper';
import SplashScreenHider from './components/SplashScreenHider';
import UpdateAppModal from './components/UpdateAppModal';
import withLocalize, {withLocalizePropTypes} from './components/withLocalize';
import CONST from './CONST';
import * as DemoActions from './libs/actions/DemoActions';
import * as EmojiPickerAction from './libs/actions/EmojiPickerAction';
import * as Report from './libs/actions/Report';
Expand Down Expand Up @@ -112,6 +113,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 +209,10 @@ function Expensify(props) {
}

return (
<DeeplinkWrapper isAuthenticated={isAuthenticated}>
<DeeplinkWrapper
isAuthenticated={isAuthenticated}
autoAuthState={autoAuthState}
>

This comment has been minimized.

Copy link
@c3024

c3024 Sep 3, 2024

Contributor

We had to pass initialURL also here for opening the correct deeplink on Desktop after clicking on the prompt on Web. Fixed here #47766.

{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 69b80bf

Please sign in to comment.