Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[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>

authored by

Eric Bailey
Dan Abramov
and committed by
GitHub
d8c8e1e8 e5fdbfe2

+10 -4
+4 -1
src/lib/notifications/notifications.ts
··· 1 1 import {useEffect} from 'react' 2 2 import * as Notifications from 'expo-notifications' 3 + import {BskyAgent} from '@atproto/api' 3 4 import {QueryClient} from '@tanstack/react-query' 4 5 5 6 import {logger} from '#/logger' 6 7 import {RQKEY as RQKEY_NOTIFS} from '#/state/queries/notifications/feed' 7 8 import {invalidateCachedUnreadPage} from '#/state/queries/notifications/unread' 8 9 import {truncateAndInvalidate} from '#/state/queries/util' 9 - import {getAgent, SessionAccount} from '#/state/session' 10 + import {SessionAccount} from '#/state/session' 10 11 import {track} from 'lib/analytics/analytics' 11 12 import {devicePlatform, isIOS} from 'platform/detection' 12 13 import {resetToTab} from '../../Navigation' ··· 18 19 : 'did:web:api.bsky.app' 19 20 20 21 export async function requestPermissionsAndRegisterToken( 22 + getAgent: () => BskyAgent, 21 23 account: SessionAccount, 22 24 ) { 23 25 // request notifications permission once the user has logged in ··· 49 51 } 50 52 51 53 export function registerTokenChangeHandler( 54 + getAgent: () => BskyAgent, 52 55 account: SessionAccount, 53 56 ): () => void { 54 57 // listens for new changes to the push token
+6 -3
src/view/shell/index.tsx
··· 13 13 import {StatusBar} from 'expo-status-bar' 14 14 import {useNavigationState} from '@react-navigation/native' 15 15 16 - import {useSession} from '#/state/session' 16 + import {getAgent, useSession} from '#/state/session' 17 17 import { 18 18 useIsDrawerOpen, 19 19 useIsDrawerSwipeDisabled, ··· 78 78 // only runs when did changes 79 79 if (currentAccount && currentAccountDid.current !== currentAccount.did) { 80 80 currentAccountDid.current = currentAccount.did 81 - notifications.requestPermissionsAndRegisterToken(currentAccount) 82 - const unsub = notifications.registerTokenChangeHandler(currentAccount) 81 + notifications.requestPermissionsAndRegisterToken(getAgent, currentAccount) 82 + const unsub = notifications.registerTokenChangeHandler( 83 + getAgent, 84 + currentAccount, 85 + ) 83 86 return unsub 84 87 } 85 88 }, [currentAccount])