diff options
author | Mary <148872143+mary-ext@users.noreply.github.com> | 2024-02-06 06:44:14 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-05 15:44:14 -0800 |
commit | 2754121f6790216a4371c98b4b1934c8c77589ec (patch) | |
tree | 830d11a94edbd7f469ff82a62559332b7d86accd /src | |
parent | 6ad5863573d5117a58630e9ed62746872ef7185c (diff) | |
download | voidsky-2754121f6790216a4371c98b4b1934c8c77589ec.tar.zst |
Bump replies (#2604)
* fix: bump replies * refactor: only bump if not at 0
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/api/feed-manip.ts | 17 |
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])) } } |