diff options
author | Eric Bailey <git@esb.lol> | 2024-04-25 15:57:45 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-25 21:57:45 +0100 |
commit | d8c8e1e854654dbcf9585d0b3bd8c87d77df2e0f (patch) | |
tree | 221f4a8e006eb7572f5847b826416f8795bed47c /src | |
parent | e5fdbfe2940e56b491fadade9260a4ce15a24946 (diff) | |
download | voidsky-d8c8e1e854654dbcf9585d0b3bd8c87d77df2e0f.tar.zst |
[Session] Drill `getAgent` into notifications handlers (#3705)
* Drill into notifications handlers (cherry picked from commit 7ac9e500866732e1f2e205bbe96e70db331e5ffb) * Thread getAgent instead --------- Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/notifications/notifications.ts | 5 | ||||
-rw-r--r-- | src/view/shell/index.tsx | 9 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/lib/notifications/notifications.ts b/src/lib/notifications/notifications.ts index e0b3d8f3d..b0bbc1bf9 100644 --- a/src/lib/notifications/notifications.ts +++ b/src/lib/notifications/notifications.ts @@ -1,12 +1,13 @@ import {useEffect} from 'react' import * as Notifications from 'expo-notifications' +import {BskyAgent} from '@atproto/api' import {QueryClient} from '@tanstack/react-query' import {logger} from '#/logger' import {RQKEY as RQKEY_NOTIFS} from '#/state/queries/notifications/feed' import {invalidateCachedUnreadPage} from '#/state/queries/notifications/unread' import {truncateAndInvalidate} from '#/state/queries/util' -import {getAgent, SessionAccount} from '#/state/session' +import {SessionAccount} from '#/state/session' import {track} from 'lib/analytics/analytics' import {devicePlatform, isIOS} from 'platform/detection' import {resetToTab} from '../../Navigation' @@ -18,6 +19,7 @@ const SERVICE_DID = (serviceUrl?: string) => : 'did:web:api.bsky.app' export async function requestPermissionsAndRegisterToken( + getAgent: () => BskyAgent, account: SessionAccount, ) { // request notifications permission once the user has logged in @@ -49,6 +51,7 @@ export async function requestPermissionsAndRegisterToken( } export function registerTokenChangeHandler( + getAgent: () => BskyAgent, account: SessionAccount, ): () => void { // listens for new changes to the push token diff --git a/src/view/shell/index.tsx b/src/view/shell/index.tsx index 562abc56c..c94b69e06 100644 --- a/src/view/shell/index.tsx +++ b/src/view/shell/index.tsx @@ -13,7 +13,7 @@ import * as NavigationBar from 'expo-navigation-bar' import {StatusBar} from 'expo-status-bar' import {useNavigationState} from '@react-navigation/native' -import {useSession} from '#/state/session' +import {getAgent, useSession} from '#/state/session' import { useIsDrawerOpen, useIsDrawerSwipeDisabled, @@ -78,8 +78,11 @@ function ShellInner() { // only runs when did changes if (currentAccount && currentAccountDid.current !== currentAccount.did) { currentAccountDid.current = currentAccount.did - notifications.requestPermissionsAndRegisterToken(currentAccount) - const unsub = notifications.registerTokenChangeHandler(currentAccount) + notifications.requestPermissionsAndRegisterToken(getAgent, currentAccount) + const unsub = notifications.registerTokenChangeHandler( + getAgent, + currentAccount, + ) return unsub } }, [currentAccount]) |