From 6571a9253a6eb53f776b99fd8ed74bd58b0bb615 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Fri, 21 Jun 2024 01:24:18 +0300 Subject: [PATCH] Wait for AppView after dismissing composer --- src/view/com/composer/Composer.tsx | 32 ++++++++++++++++-------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx index 9e2f77d4df..f7d2413afc 100644 --- a/src/view/com/composer/Composer.tsx +++ b/src/view/com/composer/Composer.tsx @@ -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(