From 884e5c92944a4d53c7e0d2847eabd576b080b4ae Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Wed, 16 Aug 2023 10:00:22 -0700 Subject: [PATCH] Fix to "Load new posts" showing sometimes when there's nothing new to show (#1191) * Fix to feed item react key value (hopefully) * Fix false-firing of load more (close #1028) --- src/lib/api/feed-manip.ts | 4 ++-- src/state/models/feeds/posts.ts | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/lib/api/feed-manip.ts b/src/lib/api/feed-manip.ts index d2bbb4e8..472289b4 100644 --- a/src/lib/api/feed-manip.ts +++ b/src/lib/api/feed-manip.ts @@ -18,8 +18,8 @@ export class FeedViewPostsSlice { constructor(public items: FeedViewPost[] = []) {} get _reactKey() { - return `slice-${this.rootItem.post.uri}-${ - this.rootItem.reason?.indexedAt || this.rootItem.post.indexedAt + return `slice-${this.items[0].post.uri}-${ + this.items[0].reason?.indexedAt || this.items[0].post.indexedAt }` } diff --git a/src/state/models/feeds/posts.ts b/src/state/models/feeds/posts.ts index 52717953..6facc27a 100644 --- a/src/state/models/feeds/posts.ts +++ b/src/state/models/feeds/posts.ts @@ -263,7 +263,16 @@ export class PostsFeedModel { return } const res = await this._getFeed({limit: 1}) - this.setHasNewLatest(res.data.feed[0]?.post.uri !== this.pollCursor) + if (res.data.feed[0]) { + const slices = this.tuner.tune(res.data.feed, this.feedTuners) + if (slices[0]) { + const sliceModel = new PostsFeedSliceModel(this.rootStore, slices[0]) + if (sliceModel.moderation.content.filter) { + return + } + this.setHasNewLatest(sliceModel.uri !== this.pollCursor) + } + } } /**