From 96f39657d7832ce3c0c4be8f58249a8cf1f156ca Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 5 Feb 2024 16:41:14 -0600 Subject: Only re-reg push noty token when account changes (#2654) --- src/view/shell/index.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/view/shell/index.tsx') 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(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 } -- cgit 1.4.1