From 0158b088da74bdd5847f10a1ad6ad4c6f6f04026 Mon Sep 17 00:00:00 2001 From: Avinash Lingaloo Date: Thu, 17 Feb 2022 11:25:10 +0400 Subject: [PATCH] MM-41890 Gekidou Long press post option - Reaction (#5978) * added reaction option * restructure files & folders Co-authored-by: Elias Nahum --- .../{components => }/options/base_option.tsx | 0 .../copy_permalink_option.tsx | 0 .../options/copy_permalink_option/index.tsx | 2 +- .../options/copy_text_option.tsx | 0 .../options/delete_post_option.tsx | 0 .../{components => }/options/edit_option.tsx | 0 .../options/follow_option.tsx | 0 .../options/mark_unread_option.tsx | 0 .../options/pin_channel_option.tsx | 0 .../{components => }/options/reply_option.tsx | 0 .../{components => }/options/save_option.tsx | 0 app/screens/post_options/post_options.tsx | 22 +++++++++---------- .../{components => }/reaction_bar/index.ts | 0 .../pick_reaction/index.tsx} | 0 .../reaction/index.tsx} | 0 .../reaction_bar/reaction_bar.tsx | 16 +++++++++----- 16 files changed, 22 insertions(+), 18 deletions(-) rename app/screens/post_options/{components => }/options/base_option.tsx (100%) rename app/screens/post_options/{components => }/options/copy_permalink_option/copy_permalink_option.tsx (100%) rename app/screens/post_options/{components => }/options/copy_permalink_option/index.tsx (96%) rename app/screens/post_options/{components => }/options/copy_text_option.tsx (100%) rename app/screens/post_options/{components => }/options/delete_post_option.tsx (100%) rename app/screens/post_options/{components => }/options/edit_option.tsx (100%) rename app/screens/post_options/{components => }/options/follow_option.tsx (100%) rename app/screens/post_options/{components => }/options/mark_unread_option.tsx (100%) rename app/screens/post_options/{components => }/options/pin_channel_option.tsx (100%) rename app/screens/post_options/{components => }/options/reply_option.tsx (100%) rename app/screens/post_options/{components => }/options/save_option.tsx (100%) rename app/screens/post_options/{components => }/reaction_bar/index.ts (100%) rename app/screens/post_options/{components/reaction_bar/components/pick_reaction.tsx => reaction_bar/pick_reaction/index.tsx} (100%) rename app/screens/post_options/{components/reaction_bar/components/reaction.tsx => reaction_bar/reaction/index.tsx} (100%) rename app/screens/post_options/{components => }/reaction_bar/reaction_bar.tsx (86%) diff --git a/app/screens/post_options/components/options/base_option.tsx b/app/screens/post_options/options/base_option.tsx similarity index 100% rename from app/screens/post_options/components/options/base_option.tsx rename to app/screens/post_options/options/base_option.tsx diff --git a/app/screens/post_options/components/options/copy_permalink_option/copy_permalink_option.tsx b/app/screens/post_options/options/copy_permalink_option/copy_permalink_option.tsx similarity index 100% rename from app/screens/post_options/components/options/copy_permalink_option/copy_permalink_option.tsx rename to app/screens/post_options/options/copy_permalink_option/copy_permalink_option.tsx diff --git a/app/screens/post_options/components/options/copy_permalink_option/index.tsx b/app/screens/post_options/options/copy_permalink_option/index.tsx similarity index 96% rename from app/screens/post_options/components/options/copy_permalink_option/index.tsx rename to app/screens/post_options/options/copy_permalink_option/index.tsx index 9c7f992f0..acc53520d 100644 --- a/app/screens/post_options/components/options/copy_permalink_option/index.tsx +++ b/app/screens/post_options/options/copy_permalink_option/index.tsx @@ -4,7 +4,7 @@ import {withDatabase} from '@nozbe/watermelondb/DatabaseProvider'; import withObservables from '@nozbe/with-observables'; import {combineLatest, of as of$} from 'rxjs'; -import {switchMap} from 'rxjs/dist/types/operators'; +import {switchMap} from 'rxjs/operators'; import {MM_TABLES, SYSTEM_IDENTIFIERS} from '@constants/database'; diff --git a/app/screens/post_options/components/options/copy_text_option.tsx b/app/screens/post_options/options/copy_text_option.tsx similarity index 100% rename from app/screens/post_options/components/options/copy_text_option.tsx rename to app/screens/post_options/options/copy_text_option.tsx diff --git a/app/screens/post_options/components/options/delete_post_option.tsx b/app/screens/post_options/options/delete_post_option.tsx similarity index 100% rename from app/screens/post_options/components/options/delete_post_option.tsx rename to app/screens/post_options/options/delete_post_option.tsx diff --git a/app/screens/post_options/components/options/edit_option.tsx b/app/screens/post_options/options/edit_option.tsx similarity index 100% rename from app/screens/post_options/components/options/edit_option.tsx rename to app/screens/post_options/options/edit_option.tsx diff --git a/app/screens/post_options/components/options/follow_option.tsx b/app/screens/post_options/options/follow_option.tsx similarity index 100% rename from app/screens/post_options/components/options/follow_option.tsx rename to app/screens/post_options/options/follow_option.tsx diff --git a/app/screens/post_options/components/options/mark_unread_option.tsx b/app/screens/post_options/options/mark_unread_option.tsx similarity index 100% rename from app/screens/post_options/components/options/mark_unread_option.tsx rename to app/screens/post_options/options/mark_unread_option.tsx diff --git a/app/screens/post_options/components/options/pin_channel_option.tsx b/app/screens/post_options/options/pin_channel_option.tsx similarity index 100% rename from app/screens/post_options/components/options/pin_channel_option.tsx rename to app/screens/post_options/options/pin_channel_option.tsx diff --git a/app/screens/post_options/components/options/reply_option.tsx b/app/screens/post_options/options/reply_option.tsx similarity index 100% rename from app/screens/post_options/components/options/reply_option.tsx rename to app/screens/post_options/options/reply_option.tsx diff --git a/app/screens/post_options/components/options/save_option.tsx b/app/screens/post_options/options/save_option.tsx similarity index 100% rename from app/screens/post_options/components/options/save_option.tsx rename to app/screens/post_options/options/save_option.tsx diff --git a/app/screens/post_options/post_options.tsx b/app/screens/post_options/post_options.tsx index ade67f6b7..1e3deaf82 100644 --- a/app/screens/post_options/post_options.tsx +++ b/app/screens/post_options/post_options.tsx @@ -9,16 +9,16 @@ import {Screens} from '@constants'; import BottomSheet from '@screens/bottom_sheet'; import {isSystemMessage} from '@utils/post'; -import CopyLinkOption from './components/options/copy_permalink_option'; -import CopyTextOption from './components/options/copy_text_option'; -import DeletePostOption from './components/options/delete_post_option'; -import EditOption from './components/options/edit_option'; -import FollowThreadOption from './components/options/follow_option'; -import MarkAsUnreadOption from './components/options/mark_unread_option'; -import PinChannelOption from './components/options/pin_channel_option'; -import ReplyOption from './components/options/reply_option'; -import SaveOption from './components/options/save_option'; -import ReactionBar from './components/reaction_bar'; +import CopyLinkOption from './options/copy_permalink_option'; +import CopyTextOption from './options/copy_text_option'; +import DeletePostOption from './options/delete_post_option'; +import EditOption from './options/edit_option'; +import FollowThreadOption from './options/follow_option'; +import MarkAsUnreadOption from './options/mark_unread_option'; +import PinChannelOption from './options/pin_channel_option'; +import ReplyOption from './options/reply_option'; +import SaveOption from './options/save_option'; +import ReactionBar from './reaction_bar'; import type PostModel from '@typings/database/models/servers/post'; @@ -66,7 +66,7 @@ const PostOptions = ({ const renderContent = () => { return ( <> - {canAddReaction && } + {canAddReaction && } {canReply && } {shouldRenderFollow && { @@ -38,17 +41,18 @@ const getStyleSheet = makeStyleSheetFromTheme((theme) => { }; }); -const ReactionBar = ({recentEmojis = []}: QuickReactionProps) => { +const ReactionBar = ({recentEmojis = [], postId}: QuickReactionProps) => { const theme = useTheme(); const intl = useIntl(); const {width} = useWindowDimensions(); + const serverUrl = useServerUrl(); const isSmallDevice = width < SMALL_ICON_BREAKPOINT; const styles = getStyleSheet(theme); const handleEmojiPress = useCallback((emoji: string) => { - // eslint-disable-next-line no-console - console.log('>>> selected this emoji', emoji); - }, []); + addReaction(serverUrl, postId, emoji); + dismissBottomSheet(Screens.POST_OPTIONS); + }, [postId, serverUrl]); const openEmojiPicker = useCallback(async () => { await dismissBottomSheet(Screens.POST_OPTIONS);