From 86ae1fc9ccd83fb54881614f57e117325f8d48c6 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Thu, 24 Mar 2022 19:24:54 -0300 Subject: [PATCH] Handle system ephemeral post --- app/components/post_list/post/avatar/avatar.tsx | 10 ++-------- app/components/post_list/post/index.ts | 2 +- app/components/post_list/post/post.tsx | 3 +-- app/components/profile_picture/index.tsx | 2 +- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/app/components/post_list/post/avatar/avatar.tsx b/app/components/post_list/post/avatar/avatar.tsx index e6ecc399c..6f6417d31 100644 --- a/app/components/post_list/post/avatar/avatar.tsx +++ b/app/components/post_list/post/avatar/avatar.tsx @@ -8,7 +8,6 @@ import FastImage from 'react-native-fast-image'; import CompassIcon from '@components/compass_icon'; import ProfilePicture from '@components/profile_picture'; -import SystemAvatar from '@components/system_avatar'; import {View as ViewConstant} from '@constants'; import {useServerUrl} from '@context/server'; import {useTheme} from '@context/theme'; @@ -25,7 +24,6 @@ type AvatarProps = { author: UserModel; enablePostIconOverride?: boolean; isAutoReponse: boolean; - isSystemPost: boolean; post: PostModel; } @@ -35,7 +33,7 @@ const style = StyleSheet.create({ }, }); -const Avatar = ({author, enablePostIconOverride, isAutoReponse, isSystemPost, post}: AvatarProps) => { +const Avatar = ({author, enablePostIconOverride, isAutoReponse, post}: AvatarProps) => { const closeButton = useRef(); const intl = useIntl(); const theme = useTheme(); @@ -47,10 +45,6 @@ const Avatar = ({author, enablePostIconOverride, isAutoReponse, isSystemPost, po // do nothing, client is not set } - if (isSystemPost && !isAutoReponse && !author.isBot) { - return (); - } - const fromWebHook = post.props?.from_webhook === 'true'; const iconOverride = enablePostIconOverride && post.props?.use_user_icon !== 'true'; if (fromWebHook && iconOverride) { @@ -125,7 +119,7 @@ const Avatar = ({author, enablePostIconOverride, isAutoReponse, isSystemPost, po author={author} size={ViewConstant.PROFILE_PICTURE_SIZE} iconSize={24} - showStatus={!isAutoReponse} + showStatus={!isAutoReponse || author.isBot} testID='post_profile_picture.profile_picture' /> ); diff --git a/app/components/post_list/post/index.ts b/app/components/post_list/post/index.ts index 3592b5468..d79b8060b 100644 --- a/app/components/post_list/post/index.ts +++ b/app/components/post_list/post/index.ts @@ -85,7 +85,7 @@ const withPost = withObservables( let isLastReply = of$(true); let isPostAddChannelMember = of$(false); const isOwner = currentUser.id === post.userId; - const author = post.author.observe(); + const author = post.userId ? post.author.observe() : of$(null); const canDelete = from$(hasPermissionForPost(post, currentUser, isOwner ? Permissions.DELETE_POST : Permissions.DELETE_OTHERS_POSTS, false)); const isEphemeral = of$(isPostEphemeral(post)); const isSaved = queryPreferencesByCategoryAndName(database, Preferences.CATEGORY_SAVED_POST, post.id).observe().pipe( diff --git a/app/components/post_list/post/post.tsx b/app/components/post_list/post/post.tsx index b13b096a8..a463862a4 100644 --- a/app/components/post_list/post/post.tsx +++ b/app/components/post_list/post/post.tsx @@ -199,12 +199,11 @@ const Post = ({ } else { postAvatar = ( - {isAutoResponder ? ( + {(isAutoResponder || isSystemPost) ? ( ) : ( )} diff --git a/app/components/profile_picture/index.tsx b/app/components/profile_picture/index.tsx index 16572e17d..8d6e7792b 100644 --- a/app/components/profile_picture/index.tsx +++ b/app/components/profile_picture/index.tsx @@ -110,7 +110,7 @@ const ProfilePicture = ({ size={size} source={source} /> - {showStatus && + {showStatus && !isBot &&