Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

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

check if a thread is muted before incrementing notif badge, filter out quotes (#2686)

* check if a thread is muted before incrementing notif badge

* some filtering for quotes and reposts

* move logic to util

* change logic

* revert always fetching

* logic for cases when we don't have a subject (count)

* unneeded change

* check subject embed in `isThreadMuted`

* remove todo

authored by

Hailey and committed by
GitHub
ca9b2a55 08a11f62

+40 -7
+40 -7
src/state/queries/notifications/util.ts
··· 6 6 AppBskyFeedPost, 7 7 AppBskyFeedRepost, 8 8 AppBskyFeedLike, 9 + AppBskyEmbedRecord, 9 10 } from '@atproto/api' 10 11 import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped' 11 12 import chunk from 'lodash.chunk' ··· 110 111 return true 111 112 } 112 113 } 113 - // TODO: thread muting is not being applied 114 - // (this requires fetching the post) 115 114 return false 116 115 } 117 116 ··· 221 220 } 222 221 } 223 222 224 - function isThreadMuted(notif: FeedNotification, mutes: string[]): boolean { 225 - if (!notif.subject) { 226 - return false 223 + export function isThreadMuted(notif: FeedNotification, threadMutes: string[]) { 224 + // If there's a subject we want to use that. This will always work on the notifications tab 225 + if (notif.subject) { 226 + const record = notif.subject.record as AppBskyFeedPost.Record 227 + // Check for a quote record 228 + if ( 229 + (record.reply && threadMutes.includes(record.reply.root.uri)) || 230 + (notif.subject.uri && threadMutes.includes(notif.subject.uri)) 231 + ) { 232 + return true 233 + } else if ( 234 + AppBskyEmbedRecord.isMain(record.embed) && 235 + threadMutes.includes(record.embed.record.uri) 236 + ) { 237 + return true 238 + } 239 + } else { 240 + // Otherwise we just do the best that we can 241 + const record = notif.notification.record 242 + if (AppBskyFeedPost.isRecord(record)) { 243 + if (record.reply && threadMutes.includes(record.reply.root.uri)) { 244 + // We can always filter replies 245 + return true 246 + } else if ( 247 + AppBskyEmbedRecord.isMain(record.embed) && 248 + threadMutes.includes(record.embed.record.uri) 249 + ) { 250 + // We can also filter quotes if the quoted post is the root 251 + return true 252 + } 253 + } else if ( 254 + AppBskyFeedRepost.isRecord(record) && 255 + threadMutes.includes(record.subject.uri) 256 + ) { 257 + // Finally we can filter reposts, again if the post is the root 258 + return true 259 + } 227 260 } 228 - const record = notif.subject.record as AppBskyFeedPost.Record // assured in fetchSubjects() 229 - return mutes.includes(record.reply?.root.uri || notif.subject.uri) 261 + 262 + return false 230 263 }