Wait for AA to load before registering push

This commit is contained in:
Eric Bailey
2025-07-08 11:55:19 -05:00
parent bebba0fea1
commit 6dcac74691
+10 -3
View File
@@ -155,12 +155,14 @@ export function useNotificationsRegistration() {
const {currentAccount} = useSession() const {currentAccount} = useSession()
const registerPushToken = useRegisterPushToken() const registerPushToken = useRegisterPushToken()
const getAndRegisterPushToken = useGetAndRegisterPushToken() const getAndRegisterPushToken = useGetAndRegisterPushToken()
const {isLoaded: isAgeAssuranceLoaded} = useAgeAssuranceContext()
useEffect(() => { useEffect(() => {
/** /**
* We want this to init right away _after_ we have a logged in user. * We want this to init right away _after_ we have a logged in user, and
* _after_ we've loaded their age assurance state.
*/ */
if (!currentAccount) return if (!currentAccount || !isAgeAssuranceLoaded) return
notyLogger.debug(`useNotificationsRegistration`) notyLogger.debug(`useNotificationsRegistration`)
@@ -189,7 +191,12 @@ export function useNotificationsRegistration() {
return () => { return () => {
subscription.remove() subscription.remove()
} }
}, [currentAccount, getAndRegisterPushToken, registerPushToken]) }, [
currentAccount,
getAndRegisterPushToken,
registerPushToken,
isAgeAssuranceLoaded,
])
} }
export function useRequestNotificationsPermission() { export function useRequestNotificationsPermission() {