about summary refs log tree commit diff
path: root/src/lib/api
diff options
context:
space:
mode:
authorMary <148872143+mary-ext@users.noreply.github.com>2024-02-06 06:44:14 +0700
committerGitHub <noreply@github.com>2024-02-05 15:44:14 -0800
commit2754121f6790216a4371c98b4b1934c8c77589ec (patch)
tree830d11a94edbd7f469ff82a62559332b7d86accd /src/lib/api
parent6ad5863573d5117a58630e9ed62746872ef7185c (diff)
downloadvoidsky-2754121f6790216a4371c98b4b1934c8c77589ec.tar.zst
Bump replies (#2604)
* fix: bump replies

* refactor: only bump if not at 0
Diffstat (limited to 'src/lib/api')
-rw-r--r--src/lib/api/feed-manip.ts17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/lib/api/feed-manip.ts b/src/lib/api/feed-manip.ts
index c964693c4..227062592 100644
--- a/src/lib/api/feed-manip.ts
+++ b/src/lib/api/feed-manip.ts
@@ -168,14 +168,25 @@ export class FeedTuner {
 
         const selfReplyUri = getSelfReplyUri(item)
         if (selfReplyUri) {
-          const parent = slices.find(item2 =>
-            item2.isNextInThread(selfReplyUri),
+          const index = slices.findIndex(slice =>
+            slice.isNextInThread(selfReplyUri),
           )
-          if (parent) {
+
+          if (index !== -1) {
+            const parent = slices[index]
+
             parent.insert(item)
+
+            // If our slice isn't currently on the top, reinsert it to the top.
+            if (index !== 0) {
+              slices.splice(index, 1)
+              slices.unshift(parent)
+            }
+
             continue
           }
         }
+
         slices.unshift(new FeedViewPostsSlice([item]))
       }
     }