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/utils` (#3703)

* Drill into notifications/util

(cherry picked from commit 84b535ed54f4fe93debcd198809bb184519c3507)

* Thread getAgent instead

---------

Co-authored-by: Dan Abramov <dan.abramov@gmail.com>

authored by

Eric Bailey
Dan Abramov
and committed by
GitHub
35005da5 a69e5679

+16 -9
+2
src/state/queries/notifications/feed.ts
··· 27 27 } from '@tanstack/react-query' 28 28 29 29 import {useMutedThreads} from '#/state/muted-threads' 30 + import {getAgent} from '#/state/session' 30 31 import {STALE} from '..' 31 32 import {useModerationOpts} from '../preferences' 32 33 import {embedViewRecordToPostView, getEmbeddedPost} from '../util' ··· 71 72 if (!page) { 72 73 page = ( 73 74 await fetchPage({ 75 + getAgent, 74 76 limit: PAGE_SIZE, 75 77 cursor: pageParam, 76 78 queryClient,
+1
src/state/queries/notifications/unread.tsx
··· 144 144 145 145 // count 146 146 const {page, indexedAt: lastIndexed} = await fetchPage({ 147 + getAgent, 147 148 cursor: undefined, 148 149 limit: 40, 149 150 queryClient,
+13 -9
src/state/queries/notifications/util.ts
··· 1 1 import { 2 - AppBskyNotificationListNotifications, 3 - ModerationOpts, 4 - moderateNotification, 2 + AppBskyEmbedRecord, 5 3 AppBskyFeedDefs, 4 + AppBskyFeedLike, 6 5 AppBskyFeedPost, 7 6 AppBskyFeedRepost, 8 - AppBskyFeedLike, 9 - AppBskyEmbedRecord, 7 + AppBskyNotificationListNotifications, 8 + BskyAgent, 9 + moderateNotification, 10 + ModerationOpts, 10 11 } from '@atproto/api' 11 - import chunk from 'lodash.chunk' 12 12 import {QueryClient} from '@tanstack/react-query' 13 - import {getAgent} from '../../session' 13 + import chunk from 'lodash.chunk' 14 + 14 15 import {precacheProfile} from '../profile' 15 - import {NotificationType, FeedNotification, FeedPage} from './types' 16 + import {FeedNotification, FeedPage, NotificationType} from './types' 16 17 17 18 const GROUPABLE_REASONS = ['like', 'repost', 'follow'] 18 19 const MS_1HR = 1e3 * 60 * 60 ··· 22 23 // = 23 24 24 25 export async function fetchPage({ 26 + getAgent, 25 27 cursor, 26 28 limit, 27 29 queryClient, ··· 29 31 threadMutes, 30 32 fetchAdditionalData, 31 33 }: { 34 + getAgent: () => BskyAgent 32 35 cursor: string | undefined 33 36 limit: number 34 37 queryClient: QueryClient ··· 53 56 // we fetch subjects of notifications (usually posts) now instead of lazily 54 57 // in the UI to avoid relayouts 55 58 if (fetchAdditionalData) { 56 - const subjects = await fetchSubjects(notifsGrouped) 59 + const subjects = await fetchSubjects(getAgent, notifsGrouped) 57 60 for (const notif of notifsGrouped) { 58 61 if (notif.subjectUri) { 59 62 notif.subject = subjects.get(notif.subjectUri) ··· 137 140 } 138 141 139 142 async function fetchSubjects( 143 + getAgent: () => BskyAgent, 140 144 groupedNotifs: FeedNotification[], 141 145 ): Promise<Map<string, AppBskyFeedDefs.PostView>> { 142 146 const uris = new Set<string>()