Bluesky app fork with some witchin' additions 💫

Show own replies before follows' replies in threads (#4882)

authored by danabra.mov and committed by

GitHub 5845e08e b291a1ed

+17 -5
+12 -1
src/state/queries/post-thread.ts
··· 136 136 node: ThreadNode, 137 137 opts: UsePreferencesQueryResponse['threadViewPrefs'], 138 138 modCache: ThreadModerationCache, 139 + currentDid: string | undefined, 139 140 ): ThreadNode { 140 141 if (node.type !== 'post') { 141 142 return node ··· 157 158 return -1 // op's own reply 158 159 } else if (bIsByOp) { 159 160 return 1 // op's own reply 161 + } 162 + 163 + const aIsBySelf = a.post.author.did === currentDid 164 + const bIsBySelf = b.post.author.did === currentDid 165 + if (aIsBySelf && bIsBySelf) { 166 + return a.post.indexedAt.localeCompare(b.post.indexedAt) // oldest 167 + } else if (aIsBySelf) { 168 + return -1 // current account's reply 169 + } else if (bIsBySelf) { 170 + return 1 // current account's reply 160 171 } 161 172 162 173 const aBlur = Boolean(modCache.get(a)?.ui('contentList').blur) ··· 195 206 } 196 207 return b.post.indexedAt.localeCompare(a.post.indexedAt) 197 208 }) 198 - node.replies.forEach(reply => sortThread(reply, opts, modCache)) 209 + node.replies.forEach(reply => sortThread(reply, opts, modCache, currentDid)) 199 210 } 200 211 return node 201 212 }
+5 -4
src/view/com/post-thread/PostThread.tsx
··· 89 89 onCanReply: (canReply: boolean) => void 90 90 onPressReply: () => unknown 91 91 }) { 92 - const {hasSession} = useSession() 92 + const {hasSession, currentAccount} = useSession() 93 93 const {_} = useLingui() 94 94 const t = useTheme() 95 95 const {isMobile, isTabletOrMobile} = useWebMediaQueries() ··· 154 154 // On the web this is not necessary because we can synchronously adjust the scroll in onContentSizeChange instead. 155 155 const [deferParents, setDeferParents] = React.useState(isNative) 156 156 157 + const currentDid = currentAccount?.did 157 158 const threadModerationCache = React.useMemo(() => { 158 159 const cache: ThreadModerationCache = new WeakMap() 159 160 if (thread && moderationOpts) { ··· 167 168 if (!threadViewPrefs || !thread) return null 168 169 169 170 return createThreadSkeleton( 170 - sortThread(thread, threadViewPrefs, threadModerationCache), 171 - hasSession, 171 + sortThread(thread, threadViewPrefs, threadModerationCache, currentDid), 172 + !!currentDid, 172 173 treeView, 173 174 threadModerationCache, 174 175 hiddenRepliesState !== HiddenRepliesState.Hide, ··· 176 177 }, [ 177 178 thread, 178 179 preferences?.threadViewPrefs, 179 - hasSession, 180 + currentDid, 180 181 treeView, 181 182 threadModerationCache, 182 183 hiddenRepliesState,