Wait for AppView after dismissing composer

This commit is contained in:
Dan Abramov
2024-06-21 01:24:18 +03:00
parent 4bba59790a
commit 6571a9253a
+17 -15
View File
@@ -305,17 +305,6 @@ export const ComposePost = observer(function ComposePost({
langs: toPostLanguages(langPrefs.postLanguage),
})
).uri
try {
await whenAppViewReady(agent, postUri, res => {
const thread = res.data.thread
return AppBskyFeedDefs.isThreadViewPost(thread)
})
} catch (waitErr: any) {
logger.error(waitErr, {
message: `Waiting for app view failed`,
})
// Keep going because the post *was* published.
}
} catch (e: any) {
logger.error(e, {
message: `Composer: create post failed`,
@@ -354,17 +343,30 @@ export const ComposePost = observer(function ComposePost({
})
if (replyTo && replyTo.uri) track('Post:Reply')
}
if (postUri && !replyTo) {
emitPostCreated()
}
setLangPrefs.savePostLanguageToHistory()
onPost?.()
onClose()
Toast.show(
replyTo
? _(msg`Your reply has been published`)
: _(msg`Your post has been published`),
)
try {
if (postUri) {
await whenAppViewReady(agent, postUri, res => {
const thread = res.data.thread
return AppBskyFeedDefs.isThreadViewPost(thread)
})
}
} catch (waitErr: any) {
logger.error(waitErr, {
message: `Waiting for app view failed`,
})
} finally {
if (postUri && !replyTo) {
emitPostCreated()
}
onPost?.()
}
}
const canPost = useMemo(