From 7e5c522718108b26d6eddc46aba47a2e086a2fe3 Mon Sep 17 00:00:00 2001 From: Hailey Date: Fri, 11 Oct 2024 09:30:30 -0700 Subject: Move intent handler to a child of `InnerApp` (#5695) --- src/lib/hooks/useIntentHandler.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/lib/hooks/useIntentHandler.ts') diff --git a/src/lib/hooks/useIntentHandler.ts b/src/lib/hooks/useIntentHandler.ts index 98ba4ec02..a33aff237 100644 --- a/src/lib/hooks/useIntentHandler.ts +++ b/src/lib/hooks/useIntentHandler.ts @@ -13,6 +13,9 @@ type IntentType = 'compose' | 'verify-email' const VALID_IMAGE_REGEX = /^[\w.:\-_/]+\|\d+(\.\d+)?\|\d+(\.\d+)?$/ +// This needs to stay outside of react to persist between account switches +let previousIntentUrl = '' + export function useIntentHandler() { const incomingUrl = Linking.useURL() const composeIntent = useComposeIntent() @@ -68,7 +71,13 @@ export function useIntentHandler() { } } - if (incomingUrl) handleIncomingURL(incomingUrl) + if (incomingUrl) { + if (previousIntentUrl === incomingUrl) { + return + } + handleIncomingURL(incomingUrl) + previousIntentUrl = incomingUrl + } }, [incomingUrl, composeIntent, verifyEmailIntent]) } -- cgit 1.4.1