Dismiss post options before executing action (#6227)

This commit is contained in:
Elias Nahum
2022-05-05 08:47:09 -04:00
committed by GitHub
parent c4e1b4ad3e
commit a0d2f33b2f
5 changed files with 9 additions and 9 deletions

View File

@@ -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 (

View File

@@ -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);
},
}],
);

View File

@@ -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 (

View File

@@ -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;

View File

@@ -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');