diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-08-03 09:44:43 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-03 09:44:43 -0700 |
commit | a63f97aef2ea70ff9f1b81d40073f36ae8e88278 (patch) | |
tree | bf93006d20d099b3dc80861e68a4bd1f53d2a097 /src/state/models/feeds | |
parent | 7256169506332c7935ced4e0babcbd07159b9402 (diff) | |
download | voidsky-a63f97aef2ea70ff9f1b81d40073f36ae8e88278.tar.zst |
Use a post and handle-resolution cache to enable quick postthread loading (#1097)
* Use a post and handle-resolution cache to enable quick postthread loading * Fix positioning of thread when loaded from cache and give more visual cues * Include parent posts in cache * Include notifications in cache
Diffstat (limited to 'src/state/models/feeds')
-rw-r--r-- | src/state/models/feeds/notifications.ts | 5 | ||||
-rw-r--r-- | src/state/models/feeds/posts.ts | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/state/models/feeds/notifications.ts b/src/state/models/feeds/notifications.ts index 05e2ef0db..b7ac3a53b 100644 --- a/src/state/models/feeds/notifications.ts +++ b/src/state/models/feeds/notifications.ts @@ -503,7 +503,9 @@ export class NotificationsFeedModel { const postsRes = await this.rootStore.agent.app.bsky.feed.getPosts({ uris: [addedUri], }) - notif.setAdditionalData(postsRes.data.posts[0]) + const post = postsRes.data.posts[0] + notif.setAdditionalData(post) + this.rootStore.posts.set(post.uri, post) } const filtered = this._filterNotifications([notif]) return filtered[0] @@ -611,6 +613,7 @@ export class NotificationsFeedModel { ), ) for (const post of postsChunks.flat()) { + this.rootStore.posts.set(post.uri, post) const models = addedPostMap.get(post.uri) if (models?.length) { for (const model of models) { diff --git a/src/state/models/feeds/posts.ts b/src/state/models/feeds/posts.ts index 4e6633d38..94d7228ed 100644 --- a/src/state/models/feeds/posts.ts +++ b/src/state/models/feeds/posts.ts @@ -374,6 +374,9 @@ export class PostsFeedModel { this.rootStore.me.follows.hydrateProfiles( res.data.feed.map(item => item.post.author), ) + for (const item of res.data.feed) { + this.rootStore.posts.fromFeedItem(item) + } const slices = this.tuner.tune(res.data.feed, this.feedTuners) @@ -405,6 +408,7 @@ export class PostsFeedModel { res: GetTimeline.Response | GetAuthorFeed.Response | GetCustomFeed.Response, ) { for (const item of res.data.feed) { + this.rootStore.posts.fromFeedItem(item) const existingSlice = this.slices.find(slice => slice.containsUri(item.post.uri), ) |