This commit is contained in:
Eric Bailey
2025-05-08 15:27:53 -05:00
parent dd01bdd91d
commit 21601390e4
3 changed files with 41 additions and 4 deletions
+16 -2
View File
@@ -165,6 +165,20 @@ export function Inner({uri}: {uri: string | undefined}) {
[refetch],
)
const optimisticOnPostReply = ({
post,
}: {
post: AppBskyFeedDefs.ThreadItemPost,
}) => (_: any, posts: AppBskyFeedDefs.ThreadItemPost[]) => {
const parentDepth = post.depth
if (posts.length) {
for (let i = 0; i < posts.length; i++) {
const p = posts[i]
p.depth = parentDepth + 1 + i
}
}
}
const {openComposer} = useOpenComposer()
const onReplyToAnchor = () => {
const anchorPost = data?.slices.find(slice => slice.type === 'threadSlice' && slice.ui.isAnchor)
@@ -181,7 +195,7 @@ export function Inner({uri}: {uri: string | undefined}) {
embed: post.embed,
moderation: anchorPost.moderation,
},
onPost: onPostReply,
onPost: optimisticOnPostReply({post:anchorPost.slice}),
})
}
@@ -209,7 +223,7 @@ export function Inner({uri}: {uri: string | undefined}) {
overrideBlur={
shownHiddenReplyKinds.has(HiddenReplyKind.Muted) && item.slice.depth > 0
}
onPostReply={onPostReply}
onPostReply={optimisticOnPostReply({post:item.slice})}
hideTopBorder={index === 0} // && !item.slice.isParentLoading} // TODO
/>
</View>