Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

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

Fix notification mark-read behaviors (#2696)

* Mark read on first notifs page fetch always; this is less optimal but it fixes a case where when the first full page's unreads are all filtered out

* Use the pre-filter indexedAt for updateSeen

authored by

Paul Frazee and committed by
GitHub
45291f17 a175922c

+25 -17
+11 -9
src/state/queries/notifications/feed.ts
··· 67 67 page = unreads.getCachedUnreadPage() 68 68 } 69 69 if (!page) { 70 - page = await fetchPage({ 71 - limit: PAGE_SIZE, 72 - cursor: pageParam, 73 - queryClient, 74 - moderationOpts, 75 - threadMutes, 76 - fetchAdditionalData: true, 77 - }) 70 + page = ( 71 + await fetchPage({ 72 + limit: PAGE_SIZE, 73 + cursor: pageParam, 74 + queryClient, 75 + moderationOpts, 76 + threadMutes, 77 + fetchAdditionalData: true, 78 + }) 79 + ).page 78 80 } 79 81 80 82 // if the first page has an unread, mark all read 81 - if (!pageParam && page.items[0] && !page.items[0].notification.isRead) { 83 + if (!pageParam) { 82 84 unreads.markAllRead() 83 85 } 84 86
+6 -4
src/state/queries/notifications/unread.tsx
··· 127 127 } 128 128 129 129 // count 130 - const page = await fetchPage({ 130 + const {page, indexedAt: lastIndexed} = await fetchPage({ 131 131 cursor: undefined, 132 132 limit: 40, 133 133 queryClient, ··· 151 151 152 152 // track last sync 153 153 const now = new Date() 154 - const lastIndexed = 155 - page.items[0] && new Date(page.items[0].notification.indexedAt) 154 + const lastIndexedDate = lastIndexed 155 + ? new Date(lastIndexed) 156 + : undefined 156 157 cacheRef.current = { 157 158 usableInFeed: !!invalidate, // will be used immediately 158 159 data: page, 159 - syncedAt: !lastIndexed || now > lastIndexed ? now : lastIndexed, 160 + syncedAt: 161 + !lastIndexedDate || now > lastIndexedDate ? now : lastIndexedDate, 160 162 unreadCount, 161 163 } 162 164
+8 -4
src/state/queries/notifications/util.ts
··· 36 36 moderationOpts: ModerationOpts | undefined 37 37 threadMutes: string[] 38 38 fetchAdditionalData: boolean 39 - }): Promise<FeedPage> { 39 + }): Promise<{page: FeedPage; indexedAt: string | undefined}> { 40 40 const res = await getAgent().listNotifications({ 41 41 limit, 42 42 cursor, 43 43 }) 44 + const indexedAt = res.data.notifications[0]?.indexedAt 44 45 45 46 // filter out notifs by mod rules 46 47 const notifs = res.data.notifications.filter( ··· 75 76 } 76 77 77 78 return { 78 - cursor: res.data.cursor, 79 - seenAt, 80 - items: notifsGrouped, 79 + page: { 80 + cursor: res.data.cursor, 81 + seenAt, 82 + items: notifsGrouped, 83 + }, 84 + indexedAt, 81 85 } 82 86 } 83 87