Fix highlighted post calc
This commit is contained in:
@@ -44,7 +44,7 @@ export function usePostThread({
|
|||||||
async queryFn() {
|
async queryFn() {
|
||||||
const {data} = await agent.app.bsky.unspecced.getPostThreadV2({
|
const {data} = await agent.app.bsky.unspecced.getPostThreadV2({
|
||||||
anchor: uri!,
|
anchor: uri!,
|
||||||
branchingFactor: params.view === 'linear' ? 1 : 10,
|
branchingFactor: params.view === 'linear' ? 1 : 100,
|
||||||
below: 10,
|
below: 10,
|
||||||
sorting: mapSortOptionsToSortID(params.sort),
|
sorting: mapSortOptionsToSortID(params.sort),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -60,11 +60,21 @@ export function flatten(
|
|||||||
const item = flattened[i]
|
const item = flattened[i]
|
||||||
|
|
||||||
// TODO should not insert if not found post etc
|
// TODO should not insert if not found post etc
|
||||||
if (item.type === 'threadPost' && item.depth === 0) {
|
if (item.type === 'threadPost') {
|
||||||
flattened.splice(i + 1, 0, {
|
if (item.ui.isAnchor) {
|
||||||
type: 'replyComposer',
|
flattened.splice(i + 1, 0, {
|
||||||
key: 'replyComposer',
|
type: 'replyComposer',
|
||||||
})
|
key: 'replyComposer',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
item.value.post.replyCount &&
|
||||||
|
item.value.post.replyCount > 0 &&
|
||||||
|
!item.ui.showChildReplyLine
|
||||||
|
) {
|
||||||
|
console.log('insert more link')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,11 +188,7 @@ export function sort(
|
|||||||
i = branch.end
|
i = branch.end
|
||||||
continue traversal
|
continue traversal
|
||||||
} else if (AppBskyUnspeccedGetPostThreadV2.isThreadItemPost(item.value)) {
|
} else if (AppBskyUnspeccedGetPostThreadV2.isThreadItemPost(item.value)) {
|
||||||
const lastSlice = items[items.length - 1]
|
const oneUp = thread.at(i - 1)
|
||||||
const isFirstReply =
|
|
||||||
lastSlice.type === 'replyComposer' ||
|
|
||||||
(lastSlice.type === 'threadPost' && lastSlice.depth === 0)
|
|
||||||
const oneUp = isFirstReply ? undefined : thread.at(i - 1)
|
|
||||||
const oneDown = thread.at(i + 1)
|
const oneDown = thread.at(i + 1)
|
||||||
const post = views.threadPost({
|
const post = views.threadPost({
|
||||||
uri: item.uri,
|
uri: item.uri,
|
||||||
|
|||||||
@@ -94,8 +94,8 @@ export function threadPost({
|
|||||||
moderation: moderatePost(value.post, moderationOpts),
|
moderation: moderatePost(value.post, moderationOpts),
|
||||||
ui: {
|
ui: {
|
||||||
isAnchor: depth === 0,
|
isAnchor: depth === 0,
|
||||||
showParentReplyLine: !!oneUp && oneUp.depth < depth,
|
showParentReplyLine: !!oneUp && oneUp.depth !== 0 && oneUp.depth < depth,
|
||||||
showChildReplyLine: !!oneDown && oneDown.depth > depth,
|
showChildReplyLine: !!oneDown && depth !== 0 && oneDown.depth > depth,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user