diff --git a/src/view/shell/index.tsx b/src/view/shell/index.tsx index 5320aebf..6b0cc680 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(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 }