Add in new optimistic insert logic
This commit is contained in:
@@ -407,15 +407,15 @@ export const ComposePost = ({
|
||||
posts = await retry(5, _e => true, async () => {
|
||||
const res = await agent.app.bsky.unspecced.getPostThreadV2({
|
||||
uri: postUri!,
|
||||
above: 0,
|
||||
above: 1,
|
||||
below: thread.posts.length - 1,
|
||||
branchingFactor: 1,
|
||||
})
|
||||
if (res.data.thread.length !== thread.posts.length) {
|
||||
const parent = res.data.thread.at(0)
|
||||
if (!AppBskyUnspeccedDefs.isThreadItemPost(parent)) {
|
||||
throw new Error(`Not ready`)
|
||||
}
|
||||
const anchor = res.data.thread.at(0)
|
||||
if (!AppBskyUnspeccedDefs.isThreadItemPost(anchor)) {
|
||||
if (res.data.thread.length !== thread.posts.length + 1) {
|
||||
throw new Error(`Not ready`)
|
||||
}
|
||||
return res.data.thread
|
||||
|
||||
@@ -161,8 +161,12 @@ export function Inner({uri}: {uri: string | undefined}) {
|
||||
({post}: {post: AppBskyUnspeccedDefs.ThreadItemPost}) =>
|
||||
(_: any, posts: AppBskyUnspeccedDefs.ThreadItemPost[]) => {
|
||||
if (posts.length) {
|
||||
// TODO get parent and update reply count?
|
||||
insertReplies(post.uri, posts)
|
||||
console.log('insert', posts)
|
||||
const parent = posts.at(0)
|
||||
const replies = posts.slice(1)
|
||||
if (parent && replies.length) {
|
||||
insertReplies(parent, replies)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user