Only re-reg push noty token when account changes (#2654)
parent
5ee802bb1f
commit
96f39657d7
|
@ -52,6 +52,8 @@ function ShellInner() {
|
||||||
const canGoBack = useNavigationState(state => !isStateAtTabRoot(state))
|
const canGoBack = useNavigationState(state => !isStateAtTabRoot(state))
|
||||||
const {hasSession, currentAccount} = useSession()
|
const {hasSession, currentAccount} = useSession()
|
||||||
const closeAnyActiveElement = useCloseAnyActiveElement()
|
const closeAnyActiveElement = useCloseAnyActiveElement()
|
||||||
|
// start undefined
|
||||||
|
const currentAccountDid = React.useRef<string | undefined>(undefined)
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
let listener = {remove() {}}
|
let listener = {remove() {}}
|
||||||
|
@ -66,13 +68,10 @@ function ShellInner() {
|
||||||
}, [closeAnyActiveElement])
|
}, [closeAnyActiveElement])
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (currentAccount) {
|
// only runs when did changes
|
||||||
|
if (currentAccount && currentAccountDid.current !== currentAccount.did) {
|
||||||
|
currentAccountDid.current = currentAccount.did
|
||||||
notifications.requestPermissionsAndRegisterToken(currentAccount)
|
notifications.requestPermissionsAndRegisterToken(currentAccount)
|
||||||
}
|
|
||||||
}, [currentAccount])
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
|
||||||
if (currentAccount) {
|
|
||||||
const unsub = notifications.registerTokenChangeHandler(currentAccount)
|
const unsub = notifications.registerTokenChangeHandler(currentAccount)
|
||||||
return unsub
|
return unsub
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue