about summary refs log tree commit diff
path: root/src/state/queries/notifications
diff options
context:
space:
mode:
Diffstat (limited to 'src/state/queries/notifications')
-rw-r--r--src/state/queries/notifications/feed.ts8
-rw-r--r--src/state/queries/notifications/unread.tsx6
2 files changed, 6 insertions, 8 deletions
diff --git a/src/state/queries/notifications/feed.ts b/src/state/queries/notifications/feed.ts
index 54bd87540..68396143c 100644
--- a/src/state/queries/notifications/feed.ts
+++ b/src/state/queries/notifications/feed.ts
@@ -4,7 +4,6 @@ import {
   AppBskyFeedRepost,
   AppBskyFeedLike,
   AppBskyNotificationListNotifications,
-  BskyAgent,
 } from '@atproto/api'
 import chunk from 'lodash.chunk'
 import {
@@ -84,7 +83,7 @@ export function useNotificationFeedQuery(opts?: {enabled?: boolean}) {
 
       // we fetch subjects of notifications (usually posts) now instead of lazily
       // in the UI to avoid relayouts
-      const subjects = await fetchSubjects(getAgent(), notifsGrouped)
+      const subjects = await fetchSubjects(notifsGrouped)
       for (const notif of notifsGrouped) {
         if (notif.subjectUri) {
           notif.subject = subjects.get(notif.subjectUri)
@@ -173,7 +172,6 @@ function groupNotifications(
 }
 
 async function fetchSubjects(
-  agent: BskyAgent,
   groupedNotifs: FeedNotification[],
 ): Promise<Map<string, AppBskyFeedDefs.PostView>> {
   const uris = new Set<string>()
@@ -185,7 +183,9 @@ async function fetchSubjects(
   const uriChunks = chunk(Array.from(uris), 25)
   const postsChunks = await Promise.all(
     uriChunks.map(uris =>
-      agent.app.bsky.feed.getPosts({uris}).then(res => res.data.posts),
+      getAgent()
+        .app.bsky.feed.getPosts({uris})
+        .then(res => res.data.posts),
     ),
   )
   const map = new Map<string, AppBskyFeedDefs.PostView>()
diff --git a/src/state/queries/notifications/unread.tsx b/src/state/queries/notifications/unread.tsx
index 36bc6528f..b93e1dc81 100644
--- a/src/state/queries/notifications/unread.tsx
+++ b/src/state/queries/notifications/unread.tsx
@@ -70,12 +70,10 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
       },
 
       async checkUnread() {
-        const agent = getAgent()
-
-        if (!agent.session) return
+        if (!getAgent().session) return
 
         // count
-        const res = await agent.listNotifications({limit: 40})
+        const res = await getAgent().listNotifications({limit: 40})
         const filtered = res.data.notifications.filter(
           notif => !notif.isRead && !shouldFilterNotif(notif, moderationOpts),
         )