Store saved feeds on the root store so we can load on init (#1793)

This commit is contained in:
Paul Frazee 2023-11-01 18:45:59 -07:00 committed by GitHub
parent f57a8cf8ba
commit 59271663b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 3 deletions

View file

@ -6,6 +6,7 @@ import {
import {RootStoreModel} from './root-store'
import {PostsFeedModel} from './feeds/posts'
import {NotificationsFeedModel} from './feeds/notifications'
import {MyFeedsUIModel} from './ui/my-feeds'
import {MyFollowsCache} from './cache/my-follows'
import {isObj, hasProp} from 'lib/type-guards'
@ -22,6 +23,7 @@ export class MeModel {
followersCount: number | undefined
mainFeed: PostsFeedModel
notifications: NotificationsFeedModel
myFeeds: MyFeedsUIModel
follows: MyFollowsCache
invites: ComAtprotoServerDefs.InviteCode[] = []
appPasswords: ComAtprotoServerListAppPasswords.AppPassword[] = []
@ -42,12 +44,14 @@ export class MeModel {
algorithm: 'reverse-chronological',
})
this.notifications = new NotificationsFeedModel(this.rootStore)
this.myFeeds = new MyFeedsUIModel(this.rootStore)
this.follows = new MyFollowsCache(this.rootStore)
}
clear() {
this.mainFeed.clear()
this.notifications.clear()
this.myFeeds.clear()
this.follows.clear()
this.rootStore.profiles.cache.clear()
this.rootStore.posts.cache.clear()
@ -111,6 +115,11 @@ export class MeModel {
/* dont await */ this.notifications.setup().catch(e => {
this.rootStore.log.error('Failed to setup notifications model', e)
})
/* dont await */ this.notifications.setup().catch(e => {
this.rootStore.log.error('Failed to setup notifications model', e)
})
this.myFeeds.clear()
/* dont await */ this.myFeeds.saved.refresh()
this.rootStore.emitSessionLoaded()
await this.fetchInviteCodes()
await this.fetchAppPasswords()

View file

@ -77,6 +77,11 @@ export class MyFeedsUIModel {
}
}
clear() {
this.saved.clear()
this.discovery.clear()
}
registerListeners() {
const dispose1 = reaction(
() => this.rootStore.preferences.savedFeeds,
@ -107,7 +112,7 @@ export class MyFeedsUIModel {
_reactKey: '__saved_feeds_header__',
type: 'saved-feeds-header',
})
if (this.saved.isLoading) {
if (this.saved.isLoading && !this.saved.hasContent) {
items.push({
_reactKey: '__saved_feeds_loading__',
type: 'saved-feeds-loading',

View file

@ -52,6 +52,10 @@ export class SavedFeedsModel {
// public api
// =
clear() {
this.all = []
}
/**
* Refresh the preferences then reload all feed infos
*/