diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-11-12 18:13:11 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-12 18:13:11 -0800 |
commit | b445c15cc99a56c2baf727d05cf53b44aef4542b (patch) | |
tree | a8b18769ba4987557d4e9b4cd72871f12fb2e1a3 /src/state/models/me.ts | |
parent | c584a3378d66459c04eee7d98560920e09c5f09f (diff) | |
download | voidsky-b445c15cc99a56c2baf727d05cf53b44aef4542b.tar.zst |
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>
Diffstat (limited to 'src/state/models/me.ts')
-rw-r--r-- | src/state/models/me.ts | 20 |
1 files changed, 0 insertions, 20 deletions
diff --git a/src/state/models/me.ts b/src/state/models/me.ts index c17fcf183..427b0e35e 100644 --- a/src/state/models/me.ts +++ b/src/state/models/me.ts @@ -4,13 +4,11 @@ import { ComAtprotoServerListAppPasswords, } from '@atproto/api' import {RootStoreModel} from './root-store' -import {NotificationsFeedModel} from './feeds/notifications' import {MyFollowsCache} from './cache/my-follows' import {isObj, hasProp} from 'lib/type-guards' import {logger} from '#/logger' const PROFILE_UPDATE_INTERVAL = 10 * 60 * 1e3 // 10min -const NOTIFS_UPDATE_INTERVAL = 30 * 1e3 // 30sec export class MeModel { did: string = '' @@ -20,12 +18,10 @@ export class MeModel { avatar: string = '' followsCount: number | undefined followersCount: number | undefined - notifications: NotificationsFeedModel follows: MyFollowsCache invites: ComAtprotoServerDefs.InviteCode[] = [] appPasswords: ComAtprotoServerListAppPasswords.AppPassword[] = [] lastProfileStateUpdate = Date.now() - lastNotifsUpdate = Date.now() get invitesAvailable() { return this.invites.filter(isInviteAvailable).length @@ -37,12 +33,10 @@ export class MeModel { {rootStore: false, serialize: false, hydrate: false}, {autoBind: true}, ) - this.notifications = new NotificationsFeedModel(this.rootStore) this.follows = new MyFollowsCache(this.rootStore) } clear() { - this.notifications.clear() this.follows.clear() this.rootStore.profiles.cache.clear() this.rootStore.posts.cache.clear() @@ -99,16 +93,6 @@ export class MeModel { if (sess.hasSession) { this.did = sess.currentSession?.did || '' await this.fetchProfile() - /* dont await */ this.notifications.setup().catch(e => { - logger.error('Failed to setup notifications model', { - error: e, - }) - }) - /* dont await */ this.notifications.setup().catch(e => { - logger.error('Failed to setup notifications model', { - error: e, - }) - }) this.rootStore.emitSessionLoaded() await this.fetchInviteCodes() await this.fetchAppPasswords() @@ -125,10 +109,6 @@ export class MeModel { await this.fetchInviteCodes() await this.fetchAppPasswords() } - if (Date.now() - this.lastNotifsUpdate > NOTIFS_UPDATE_INTERVAL) { - this.lastNotifsUpdate = Date.now() - await this.notifications.syncQueue() - } } async fetchProfile() { |