diff options
author | Paul Frazee <pfrazee@gmail.com> | 2022-11-10 16:30:14 -0600 |
---|---|---|
committer | Paul Frazee <pfrazee@gmail.com> | 2022-11-10 16:30:14 -0600 |
commit | d3707f30e30bb717e95b27cc83a1121815b475b5 (patch) | |
tree | 57fcb61e9e937949526713a778e171a6676c9acf /src/state/models/notifications-view.ts | |
parent | ecf56729b0da535f1d0b794268c7856836e76bd6 (diff) | |
download | voidsky-d3707f30e30bb717e95b27cc83a1121815b475b5.tar.zst |
Implement scene invitation and membership controls
Diffstat (limited to 'src/state/models/notifications-view.ts')
-rw-r--r-- | src/state/models/notifications-view.ts | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/src/state/models/notifications-view.ts b/src/state/models/notifications-view.ts index 7b1508a19..43bc0cb4d 100644 --- a/src/state/models/notifications-view.ts +++ b/src/state/models/notifications-view.ts @@ -1,7 +1,11 @@ import {makeAutoObservable} from 'mobx' import * as ListNotifications from '../../third-party/api/src/client/types/app/bsky/notification/list' import {RootStoreModel} from './root-store' +import {Declaration} from './_common' import {hasProp} from '../lib/type-guards' +import {APP_BSKY_GRAPH} from '../../third-party/api' + +const UNGROUPABLE_REASONS = ['trend', 'assertion'] export interface GroupedNotification extends ListNotifications.Notification { additional?: ListNotifications.Notification[] @@ -18,7 +22,8 @@ export class NotificationsViewItemModel implements GroupedNotification { did: string handle: string displayName?: string - } = {did: '', handle: ''} + declaration: Declaration + } = {did: '', handle: '', declaration: {cid: '', actorType: ''}} reason: string = '' reasonSubject?: string record: any = {} @@ -65,6 +70,10 @@ export class NotificationsViewItemModel implements GroupedNotification { return this.reason === 'repost' } + get isTrend() { + return this.reason === 'trend' + } + get isReply() { return this.reason === 'reply' } @@ -73,6 +82,16 @@ export class NotificationsViewItemModel implements GroupedNotification { return this.reason === 'follow' } + get isAssertion() { + return this.reason === 'assertion' + } + + get isInvite() { + return ( + this.isAssertion && this.record.assertion === APP_BSKY_GRAPH.AssertMember + ) + } + get subjectUri() { if (this.reasonSubject) { return this.reasonSubject @@ -316,16 +335,18 @@ function groupNotifications( const items2: GroupedNotification[] = [] for (const item of items) { let grouped = false - for (const item2 of items2) { - if ( - item.reason === item2.reason && - item.reasonSubject === item2.reasonSubject && - item.author.did !== item2.author.did - ) { - item2.additional = item2.additional || [] - item2.additional.push(item) - grouped = true - break + if (!UNGROUPABLE_REASONS.includes(item.reason)) { + for (const item2 of items2) { + if ( + item.reason === item2.reason && + item.reasonSubject === item2.reasonSubject && + item.author.did !== item2.author.did + ) { + item2.additional = item2.additional || [] + item2.additional.push(item) + grouped = true + break + } } } if (!grouped) { |