From af07f511f78e783ff39cd17b3869ebda8e4614b5 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Thu, 2 Mar 2023 12:46:18 +0200 Subject: [PATCH] use sourceScreen instead of location in post options (#7176) --- .../combined_user_activity/combined_user_activity.tsx | 4 ++-- app/screens/post_options/index.ts | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/components/post_list/combined_user_activity/combined_user_activity.tsx b/app/components/post_list/combined_user_activity/combined_user_activity.tsx index 5182d56248..aae18095c0 100644 --- a/app/components/post_list/combined_user_activity/combined_user_activity.tsx +++ b/app/components/post_list/combined_user_activity/combined_user_activity.tsx @@ -108,7 +108,7 @@ const CombinedUserActivity = ({ return; } - const passProps = {post}; + const passProps = {post, sourceScreen: location}; Keyboard.dismiss(); const title = isTablet ? intl.formatMessage({id: 'post.options.title', defaultMessage: 'Options'}) : ''; @@ -117,7 +117,7 @@ const CombinedUserActivity = ({ } else { showModalOverCurrentContext(Screens.POST_OPTIONS, passProps, bottomSheetModalOptions(theme)); } - }, [post, canDelete, isTablet, intl]); + }, [post, canDelete, isTablet, intl, location]); const renderMessage = (postType: string, userIds: string[], actorId: string) => { let actor = ''; diff --git a/app/screens/post_options/index.ts b/app/screens/post_options/index.ts index ed29f3457a..6488fe5a63 100644 --- a/app/screens/post_options/index.ts +++ b/app/screens/post_options/index.ts @@ -31,12 +31,13 @@ import type ChannelModel from '@typings/database/models/servers/channel'; import type PostModel from '@typings/database/models/servers/post'; import type ReactionModel from '@typings/database/models/servers/reaction'; import type UserModel from '@typings/database/models/servers/user'; +import type {AvailableScreens} from '@typings/screens/navigation'; type EnhancedProps = WithDatabaseArgs & { combinedPost?: Post | PostModel; post: PostModel; showAddReaction: boolean; - location: string; + sourceScreen: AvailableScreens; serverUrl: string; } @@ -75,7 +76,7 @@ const withPost = withObservables([], ({post, database}: {post: Post | PostModel} }; }); -const enhanced = withObservables([], ({combinedPost, post, showAddReaction, location, database, serverUrl}: EnhancedProps) => { +const enhanced = withObservables([], ({combinedPost, post, showAddReaction, sourceScreen, database, serverUrl}: EnhancedProps) => { const channel = observeChannel(database, post.channelId); const channelIsArchived = channel.pipe(switchMap((ch: ChannelModel) => of$(ch.deleteAt !== 0))); const currentUser = observeCurrentUser(database); @@ -112,7 +113,7 @@ const enhanced = withObservables([], ({combinedPost, post, showAddReaction, loca ); const canReply = combineLatest([channelIsArchived, channelIsReadOnly, canPostPermission]).pipe(switchMap(([isArchived, isReadOnly, canPost]) => { - return of$(!isArchived && !isReadOnly && location !== Screens.THREAD && !isSystemMessage(post) && canPost); + return of$(!isArchived && !isReadOnly && sourceScreen !== Screens.THREAD && !isSystemMessage(post) && canPost); })); const canPin = combineLatest([channelIsArchived, channelIsReadOnly]).pipe(switchMap(([isArchived, isReadOnly]) => {