Refactor notifications to use react-query (#1878)
* Move broadcast channel to lib * Refactor view/com/post/Post and remove temporary 2 components * Add useModerationOpts hook * Refactor notifications to use react-query * Fix: only trigger updates in useModerationOpts when the values have changed * Implement unread notification tracking * Add moderation filtering to notifications * Handle native/push notifications * Remove dead code --------- Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
parent
c584a3378d
commit
b445c15cc9
29 changed files with 941 additions and 1739 deletions
38
src/state/queries/notifications/util.ts
Normal file
38
src/state/queries/notifications/util.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
import {
|
||||
AppBskyNotificationListNotifications,
|
||||
ModerationOpts,
|
||||
moderateProfile,
|
||||
moderatePost,
|
||||
} from '@atproto/api'
|
||||
|
||||
// TODO this should be in the sdk as moderateNotification -prf
|
||||
export function shouldFilterNotif(
|
||||
notif: AppBskyNotificationListNotifications.Notification,
|
||||
moderationOpts: ModerationOpts | undefined,
|
||||
): boolean {
|
||||
if (!moderationOpts) {
|
||||
return false
|
||||
}
|
||||
const profile = moderateProfile(notif.author, moderationOpts)
|
||||
if (
|
||||
profile.account.filter ||
|
||||
profile.profile.filter ||
|
||||
notif.author.viewer?.muted
|
||||
) {
|
||||
return true
|
||||
}
|
||||
if (
|
||||
notif.type === 'reply' ||
|
||||
notif.type === 'quote' ||
|
||||
notif.type === 'mention'
|
||||
) {
|
||||
// NOTE: the notification overlaps the post enough for this to work
|
||||
const post = moderatePost(notif, moderationOpts)
|
||||
if (post.content.filter) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
// TODO: thread muting is not being applied
|
||||
// (this requires fetching the post)
|
||||
return false
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue