diff options
author | dan <dan.abramov@gmail.com> | 2024-08-06 17:12:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-06 17:12:27 +0100 |
commit | 5845e08eeea151deb75bb21ceaa33f7a973870e3 (patch) | |
tree | b0e3e8437db37c4e52789182079fde4f68cd2f2b /src/state/queries/post-thread.ts | |
parent | b291a1ed8a1706f30f117d691d85508ffad342f2 (diff) | |
download | voidsky-5845e08eeea151deb75bb21ceaa33f7a973870e3.tar.zst |
Show own replies before follows' replies in threads (#4882)
Diffstat (limited to 'src/state/queries/post-thread.ts')
-rw-r--r-- | src/state/queries/post-thread.ts | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/state/queries/post-thread.ts b/src/state/queries/post-thread.ts index db85e8a17..c01b96ed8 100644 --- a/src/state/queries/post-thread.ts +++ b/src/state/queries/post-thread.ts @@ -136,6 +136,7 @@ export function sortThread( node: ThreadNode, opts: UsePreferencesQueryResponse['threadViewPrefs'], modCache: ThreadModerationCache, + currentDid: string | undefined, ): ThreadNode { if (node.type !== 'post') { return node @@ -159,6 +160,16 @@ export function sortThread( return 1 // op's own reply } + const aIsBySelf = a.post.author.did === currentDid + const bIsBySelf = b.post.author.did === currentDid + if (aIsBySelf && bIsBySelf) { + return a.post.indexedAt.localeCompare(b.post.indexedAt) // oldest + } else if (aIsBySelf) { + return -1 // current account's reply + } else if (bIsBySelf) { + return 1 // current account's reply + } + const aBlur = Boolean(modCache.get(a)?.ui('contentList').blur) const bBlur = Boolean(modCache.get(b)?.ui('contentList').blur) if (aBlur !== bBlur) { @@ -195,7 +206,7 @@ export function sortThread( } return b.post.indexedAt.localeCompare(a.post.indexedAt) }) - node.replies.forEach(reply => sortThread(reply, opts, modCache)) + node.replies.forEach(reply => sortThread(reply, opts, modCache, currentDid)) } return node } |