about summary refs log tree commit diff
path: root/src/lib/hooks
diff options
context:
space:
mode:
authorHailey <me@haileyok.com>2024-10-11 09:30:30 -0700
committerGitHub <noreply@github.com>2024-10-11 09:30:30 -0700
commit7e5c522718108b26d6eddc46aba47a2e086a2fe3 (patch)
treeecf9a76893fcaa58c19aa1a5f5441ad545cc0fbb /src/lib/hooks
parent8c6384175c8343c0cdc14b4fbefd53127f3f1866 (diff)
downloadvoidsky-7e5c522718108b26d6eddc46aba47a2e086a2fe3.tar.zst
Move intent handler to a child of `InnerApp` (#5695)
Diffstat (limited to 'src/lib/hooks')
-rw-r--r--src/lib/hooks/useIntentHandler.ts11
1 files changed, 10 insertions, 1 deletions
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])
 }