about summary refs log tree commit diff
path: root/src/view
diff options
context:
space:
mode:
authorEric Bailey <git@esb.lol>2024-02-05 16:41:14 -0600
committerGitHub <noreply@github.com>2024-02-05 14:41:14 -0800
commit96f39657d7832ce3c0c4be8f58249a8cf1f156ca (patch)
treeaa294f8c8d56aa28159a9faa51aca1743397ca94 /src/view
parent5ee802bb1f09fee61e116c95f526e6a562dcdc49 (diff)
downloadvoidsky-96f39657d7832ce3c0c4be8f58249a8cf1f156ca.tar.zst
Only re-reg push noty token when account changes (#2654)
Diffstat (limited to 'src/view')
-rw-r--r--src/view/shell/index.tsx11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/view/shell/index.tsx b/src/view/shell/index.tsx
index 5320aebfc..6b0cc6808 100644
--- a/src/view/shell/index.tsx
+++ b/src/view/shell/index.tsx
@@ -52,6 +52,8 @@ function ShellInner() {
   const canGoBack = useNavigationState(state => !isStateAtTabRoot(state))
   const {hasSession, currentAccount} = useSession()
   const closeAnyActiveElement = useCloseAnyActiveElement()
+  // start undefined
+  const currentAccountDid = React.useRef<string | undefined>(undefined)
 
   React.useEffect(() => {
     let listener = {remove() {}}
@@ -66,13 +68,10 @@ function ShellInner() {
   }, [closeAnyActiveElement])
 
   React.useEffect(() => {
-    if (currentAccount) {
+    // only runs when did changes
+    if (currentAccount && currentAccountDid.current !== currentAccount.did) {
+      currentAccountDid.current = currentAccount.did
       notifications.requestPermissionsAndRegisterToken(currentAccount)
-    }
-  }, [currentAccount])
-
-  React.useEffect(() => {
-    if (currentAccount) {
       const unsub = notifications.registerTokenChangeHandler(currentAccount)
       return unsub
     }