Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improvements to feed assembly to avoid possible state issues (#1318)

* Avoid potential dropped posts due to pruning when checking for latest

* Add a sanity check to ensure dup react keys never occur (close #1315)

authored by

Paul Frazee and committed by
GitHub
5ee754e6 e2f0770b

+18 -4
+6 -3
src/lib/api/feed-manip.ts
··· 105 105 tune( 106 106 feed: FeedViewPost[], 107 107 tunerFns: FeedTunerFn[] = [], 108 + {dryRun}: {dryRun: boolean} = {dryRun: false}, 108 109 ): FeedViewPostsSlice[] { 109 110 let slices: FeedViewPostsSlice[] = [] 110 111 ··· 156 157 } 157 158 } 158 159 159 - for (const slice of slices) { 160 - for (const item of slice.items) { 161 - this.seenUris.add(item.post.uri) 160 + if (!dryRun) { 161 + for (const slice of slices) { 162 + for (const item of slice.items) { 163 + this.seenUris.add(item.post.uri) 164 + } 162 165 } 163 166 } 164 167
+12 -1
src/state/models/feeds/posts.ts
··· 277 277 } 278 278 const res = await this._getFeed({limit: 1}) 279 279 if (res.data.feed[0]) { 280 - const slices = this.tuner.tune(res.data.feed, this.feedTuners) 280 + const slices = this.tuner.tune(res.data.feed, this.feedTuners, { 281 + dryRun: true, 282 + }) 281 283 if (slices[0]) { 282 284 const sliceModel = new PostsFeedSliceModel(this.rootStore, slices[0]) 283 285 if (sliceModel.moderation.content.filter) { ··· 374 376 const toAppend: PostsFeedSliceModel[] = [] 375 377 for (const slice of slices) { 376 378 const sliceModel = new PostsFeedSliceModel(this.rootStore, slice) 379 + const dupTest = (item: PostsFeedSliceModel) => 380 + item._reactKey === sliceModel._reactKey 381 + // sanity check 382 + // if a duplicate _reactKey passes through, the UI breaks hard 383 + if (!replace) { 384 + if (this.slices.find(dupTest) || toAppend.find(dupTest)) { 385 + continue 386 + } 387 + } 377 388 toAppend.push(sliceModel) 378 389 } 379 390 runInAction(() => {