about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2022-12-13 15:51:54 -0600
committerPaul Frazee <pfrazee@gmail.com>2022-12-13 15:51:54 -0600
commitebfa6e5581b9684ab3fe008749c9f13efce7f6a9 (patch)
tree7db9327e175454b9a5ee9a15be2b634cfe6b0e34 /src
parentb5a50478d963ce773155b77d1084e679fe0f847f (diff)
downloadvoidsky-ebfa6e5581b9684ab3fe008749c9f13efce7f6a9.tar.zst
Fix: avoid dup keynames in posts feed
Diffstat (limited to 'src')
-rw-r--r--src/state/models/feed-view.ts8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/state/models/feed-view.ts b/src/state/models/feed-view.ts
index 18b3e4c1a..75ed82684 100644
--- a/src/state/models/feed-view.ts
+++ b/src/state/models/feed-view.ts
@@ -12,6 +12,8 @@ import {isObj, hasProp} from '../lib/type-guards'
 
 const PAGE_SIZE = 30
 
+let _idCounter = 0
+
 type FeedItem = GetTimeline.FeedItem | GetAuthorFeed.FeedItem
 type FeedItemWithThreadMeta = FeedItem & {
   _isThreadParent?: boolean
@@ -445,7 +447,6 @@ export class FeedModel {
   ) {
     this.loadMoreCursor = res.data.cursor
     this.hasMore = !!this.loadMoreCursor
-    let counter = this.feed.length
 
     // HACK 1
     // rearrange the posts to represent threads
@@ -462,7 +463,7 @@ export class FeedModel {
     for (const item of reorgedFeed) {
       const itemModel = new FeedItemModel(
         this.rootStore,
-        `item-${counter++}`,
+        `item-${_idCounter++}`,
         item,
       )
       if (itemModel.needsAdditionalData) {
@@ -488,7 +489,6 @@ export class FeedModel {
     res: GetTimeline.Response | GetAuthorFeed.Response,
   ) {
     this.pollCursor = res.data.feed[0]?.uri
-    let counter = this.feed.length
 
     const promises = []
     const toPrepend: FeedItemModel[] = []
@@ -499,7 +499,7 @@ export class FeedModel {
 
       const itemModel = new FeedItemModel(
         this.rootStore,
-        `item-${counter++}`,
+        `item-${_idCounter++}`,
         item,
       )
       if (itemModel.needsAdditionalData) {