Fix issue that caused repost & trend data to get lost on feed updates

zio/stable
Paul Frazee 2022-12-13 15:17:18 -06:00
parent 9a99c9c8c8
commit 8af8d782c7
1 changed files with 5 additions and 4 deletions

View File

@ -520,10 +520,11 @@ export class FeedModel {
private _updateAll(res: GetTimeline.Response | GetAuthorFeed.Response) { private _updateAll(res: GetTimeline.Response | GetAuthorFeed.Response) {
for (const item of res.data.feed) { for (const item of res.data.feed) {
const existingItem = this.feed.find( const existingItem = this.feed.find(
// this find function has a key subtley- the indexedAt comparison // HACK: need to find the reposts and trends item, so we have to check for that -prf
// the reason for this is reposts: they set the URI of the original post, not of the repost record item2 =>
// the indexedAt time will be for the repost however, so we use that to help us item.uri === item2.uri &&
item2 => item.uri === item2.uri && item.indexedAt === item2.indexedAt, item.repostedBy?.did === item2.repostedBy?.did &&
item.trendedBy?.did === item2.trendedBy?.did,
) )
if (existingItem) { if (existingItem) {
existingItem.copy(item) existingItem.copy(item)