diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-11-15 17:17:50 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-15 17:17:50 -0800 |
commit | 6616b2bff098ff4a5e464c175edf2446dae0cc88 (patch) | |
tree | fb314b51dd3d17b488fa2971735aa7c19176493b /src/lib/notifications | |
parent | f23e9978d839322aab7304d2b6f183722e3ad4c1 (diff) | |
download | voidsky-6616b2bff098ff4a5e464c175edf2446dae0cc88.tar.zst |
Shell behaviors update (react-query refactor) (#1915)
* Move tick-every-minute into a hook/context * Move soft-reset event out of the shell model * Update soft-reset listener on new search page * Implement session-loaded and session-dropped events * Update analytics and push-notifications to use new session system
Diffstat (limited to 'src/lib/notifications')
-rw-r--r-- | src/lib/notifications/notifications.ts | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/lib/notifications/notifications.ts b/src/lib/notifications/notifications.ts index d46479a05..2320e1c7b 100644 --- a/src/lib/notifications/notifications.ts +++ b/src/lib/notifications/notifications.ts @@ -1,19 +1,19 @@ import * as Notifications from 'expo-notifications' import {QueryClient} from '@tanstack/react-query' -import {RootStoreModel} from '../../state' import {resetToTab} from '../../Navigation' import {devicePlatform, isIOS} from 'platform/detection' import {track} from 'lib/analytics/analytics' import {logger} from '#/logger' import {RQKEY as RQKEY_NOTIFS} from '#/state/queries/notifications/feed' +import {listenSessionLoaded} from '#/state/events' const SERVICE_DID = (serviceUrl?: string) => serviceUrl?.includes('staging') ? 'did:web:api.staging.bsky.dev' : 'did:web:api.bsky.app' -export function init(store: RootStoreModel, queryClient: QueryClient) { - store.onSessionLoaded(async () => { +export function init(queryClient: QueryClient) { + listenSessionLoaded(async (account, agent) => { // request notifications permission once the user has logged in const perms = await Notifications.getPermissionsAsync() if (!perms.granted) { @@ -24,8 +24,8 @@ export function init(store: RootStoreModel, queryClient: QueryClient) { const token = await getPushToken() if (token) { try { - await store.agent.api.app.bsky.notification.registerPush({ - serviceDid: SERVICE_DID(store.session.data?.service), + await agent.api.app.bsky.notification.registerPush({ + serviceDid: SERVICE_DID(account.service), platform: devicePlatform, token: token.data, appId: 'xyz.blueskyweb.app', @@ -53,8 +53,8 @@ export function init(store: RootStoreModel, queryClient: QueryClient) { ) if (t) { try { - await store.agent.api.app.bsky.notification.registerPush({ - serviceDid: SERVICE_DID(store.session.data?.service), + await agent.api.app.bsky.notification.registerPush({ + serviceDid: SERVICE_DID(account.service), platform: devicePlatform, token: t, appId: 'xyz.blueskyweb.app', |