Show own replies before follows' replies in threads (#4882)
This commit is contained in:
parent
b291a1ed8a
commit
5845e08eee
2 changed files with 17 additions and 5 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue