From 39e5c2c07a86c27ef18ff9805097ab605cde873c Mon Sep 17 00:00:00 2001 From: Avinash Lingaloo Date: Mon, 21 Feb 2022 16:29:58 +0400 Subject: [PATCH] MM-41941 Gekidou Long Press Menu Post options - Reply (#5986) * implementing reply option * update reply option * corrections --- .../post_list/post/header/reply/index.tsx | 6 ++++-- app/components/post_list/post/post.tsx | 7 ++++--- .../post_options/options/reply_option.tsx | 21 ++++++++++++++----- app/screens/post_options/post_options.tsx | 2 +- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/app/components/post_list/post/header/reply/index.tsx b/app/components/post_list/post/header/reply/index.tsx index 18d942e9f..ee7ab591a 100644 --- a/app/components/post_list/post/header/reply/index.tsx +++ b/app/components/post_list/post/header/reply/index.tsx @@ -2,11 +2,12 @@ // See LICENSE.txt for license information. import React, {useCallback} from 'react'; -import {DeviceEventEmitter, Text, View} from 'react-native'; +import {Text, View} from 'react-native'; import CompassIcon from '@components/compass_icon'; import TouchableWithFeedback from '@components/touchable_with_feedback'; import {SEARCH} from '@constants/screens'; +import {goToScreen} from '@screens/navigation'; import {preventDoubleTap} from '@utils/tap'; import {makeStyleSheetFromTheme} from '@utils/theme'; @@ -47,7 +48,8 @@ const HeaderReply = ({commentCount, location, post, theme}: HeaderReplyProps) => const style = getStyleSheet(theme); const onPress = useCallback(preventDoubleTap(() => { - DeviceEventEmitter.emit('goToThread', post); + // https://mattermost.atlassian.net/browse/MM-39708 + goToScreen('THREADS_SCREEN_NOT_IMPLEMENTED_YET', '', {post}); }), []); return ( diff --git a/app/components/post_list/post/post.tsx b/app/components/post_list/post/post.tsx index 61f685835..7bcb9fdf9 100644 --- a/app/components/post_list/post/post.tsx +++ b/app/components/post_list/post/post.tsx @@ -3,7 +3,7 @@ import React, {ReactNode, useMemo, useRef} from 'react'; import {useIntl} from 'react-intl'; -import {DeviceEventEmitter, Keyboard, Platform, StyleProp, View, ViewStyle} from 'react-native'; +import {Keyboard, Platform, StyleProp, View, ViewStyle} from 'react-native'; import {showPermalink} from '@actions/local/permalink'; import {removePost} from '@actions/local/post'; @@ -14,7 +14,7 @@ import * as Screens from '@constants/screens'; import {useServerUrl} from '@context/server'; import {useTheme} from '@context/theme'; import {useIsTablet} from '@hooks/device'; -import {bottomSheetModalOptions, showModal, showModalOverCurrentContext} from '@screens/navigation'; +import {bottomSheetModalOptions, goToScreen, showModal, showModalOverCurrentContext} from '@screens/navigation'; import {fromAutoResponder, isFromWebhook, isPostPendingOrFailed, isSystemMessage} from '@utils/post'; import {preventDoubleTap} from '@utils/tap'; import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme'; @@ -137,7 +137,8 @@ const Post = ({ const isValidSystemMessage = isAutoResponder || !isSystemPost; if (post.deleteAt === 0 && isValidSystemMessage && !isPendingOrFailed) { if ([Screens.CHANNEL, Screens.PERMALINK].includes(location)) { - DeviceEventEmitter.emit('goToThread', post); + // https://mattermost.atlassian.net/browse/MM-39708 + goToScreen('THREADS_SCREEN_NOT_IMPLEMENTED_YET', '', {post}); } } else if ((isEphemeral || post.deleteAt > 0)) { removePost(serverUrl, post); diff --git a/app/screens/post_options/options/reply_option.tsx b/app/screens/post_options/options/reply_option.tsx index ca29647ca..3d0721891 100644 --- a/app/screens/post_options/options/reply_option.tsx +++ b/app/screens/post_options/options/reply_option.tsx @@ -1,16 +1,27 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import React from 'react'; +import React, {useCallback} from 'react'; +import {Screens} from '@constants'; import {t} from '@i18n'; +import {dismissBottomSheet, goToScreen} from '@screens/navigation'; import BaseOption from './base_option'; -const ReplyOption = () => { - const handleReply = () => { - //todo: - }; +import type PostModel from '@typings/database/models/servers/post'; + +type Props = { + post: PostModel; +} +const ReplyOption = ({post}: Props) => { + const handleReply = useCallback(() => { + //todo: @anurag Change below screen name to Screens.THREAD once implemented + // https://mattermost.atlassian.net/browse/MM-39708 + goToScreen('THREADS_SCREEN_NOT_IMPLEMENTED_YET', '', {post}); + dismissBottomSheet(Screens.POST_OPTIONS); + }, [post]); + return ( {canAddReaction && } - {canReply && } + {canReply && } {shouldRenderFollow &&