From a0d2f33b2fb7193b5b62cb046304fff9a9805255 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Thu, 5 May 2022 08:47:09 -0400 Subject: [PATCH] Dismiss post options before executing action (#6227) --- app/screens/post_options/options/copy_text_option.tsx | 4 ++-- app/screens/post_options/options/delete_post_option.tsx | 4 ++-- app/screens/post_options/options/mark_unread_option.tsx | 4 ++-- app/screens/post_options/options/pin_channel_option.tsx | 4 ++-- app/screens/thread_options/options/mark_as_unread_option.tsx | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/screens/post_options/options/copy_text_option.tsx b/app/screens/post_options/options/copy_text_option.tsx index 27eefd4c61..696932b9fe 100644 --- a/app/screens/post_options/options/copy_text_option.tsx +++ b/app/screens/post_options/options/copy_text_option.tsx @@ -13,9 +13,9 @@ type Props = { postMessage: string; } const CopyTextOption = ({postMessage}: Props) => { - const handleCopyText = useCallback(() => { + const handleCopyText = useCallback(async () => { + await dismissBottomSheet(Screens.POST_OPTIONS); Clipboard.setString(postMessage); - dismissBottomSheet(Screens.POST_OPTIONS); }, [postMessage]); return ( diff --git a/app/screens/post_options/options/delete_post_option.tsx b/app/screens/post_options/options/delete_post_option.tsx index ae5314ceb7..88eea8e79c 100644 --- a/app/screens/post_options/options/delete_post_option.tsx +++ b/app/screens/post_options/options/delete_post_option.tsx @@ -35,9 +35,9 @@ const DeletePostOption = ({combinedPost, post}: Props) => { }, { text: formatMessage({id: 'post_info.del', defaultMessage: 'Delete'}), style: 'destructive', - onPress: () => { + onPress: async () => { + await dismissBottomSheet(Screens.POST_OPTIONS); deletePost(serverUrl, combinedPost || post); - dismissBottomSheet(Screens.POST_OPTIONS); }, }], ); diff --git a/app/screens/post_options/options/mark_unread_option.tsx b/app/screens/post_options/options/mark_unread_option.tsx index 60ccf90ec7..24ad73415a 100644 --- a/app/screens/post_options/options/mark_unread_option.tsx +++ b/app/screens/post_options/options/mark_unread_option.tsx @@ -17,9 +17,9 @@ type Props = { const MarkAsUnreadOption = ({postId}: Props) => { const serverUrl = useServerUrl(); - const onPress = useCallback(() => { + const onPress = useCallback(async () => { + await dismissBottomSheet(Screens.POST_OPTIONS); markPostAsUnread(serverUrl, postId); - dismissBottomSheet(Screens.POST_OPTIONS); }, [serverUrl, postId]); return ( diff --git a/app/screens/post_options/options/pin_channel_option.tsx b/app/screens/post_options/options/pin_channel_option.tsx index 555585a7d8..8b87fa6b6c 100644 --- a/app/screens/post_options/options/pin_channel_option.tsx +++ b/app/screens/post_options/options/pin_channel_option.tsx @@ -18,9 +18,9 @@ type PinChannelProps = { const PinChannelOption = ({isPostPinned, postId}: PinChannelProps) => { const serverUrl = useServerUrl(); - const onPress = useCallback(() => { + const onPress = useCallback(async () => { + await dismissBottomSheet(Screens.POST_OPTIONS); togglePinPost(serverUrl, postId); - dismissBottomSheet(Screens.POST_OPTIONS); }, [postId, serverUrl]); let defaultMessage; diff --git a/app/screens/thread_options/options/mark_as_unread_option.tsx b/app/screens/thread_options/options/mark_as_unread_option.tsx index db8fd8c166..43dff75749 100644 --- a/app/screens/thread_options/options/mark_as_unread_option.tsx +++ b/app/screens/thread_options/options/mark_as_unread_option.tsx @@ -22,9 +22,9 @@ const MarkAsUnreadOption = ({teamId, thread, post}: Props) => { const serverUrl = useServerUrl(); const onHandlePress = useCallback(async () => { + await dismissBottomSheet(Screens.THREAD_OPTIONS); const timestamp = thread.unreadReplies ? Date.now() : post.createAt; updateThreadRead(serverUrl, teamId, thread.id, timestamp); - dismissBottomSheet(Screens.THREAD_OPTIONS); }, [serverUrl, thread]); const id = thread.unreadReplies ? t('global_threads.options.mark_as_read') : t('mobile.post_info.mark_unread');