diff --git a/app/components/user_item/user_item.tsx b/app/components/user_item/user_item.tsx index 6af46a5cac4..84325d96ba6 100644 --- a/app/components/user_item/user_item.tsx +++ b/app/components/user_item/user_item.tsx @@ -13,13 +13,13 @@ import {useTheme} from '@context/theme'; import {nonBreakingString} from '@utils/strings'; import {makeStyleSheetFromTheme, changeOpacity} from '@utils/theme'; import {typography} from '@utils/typography'; -import {displayUsername, getUserCustomStatus, isBot, isCustomStatusExpired, isGuest, isShared} from '@utils/user'; +import {displayUsername, getUserCustomStatus, isBot, isCustomStatusExpired, isDeactivated, isGuest, isShared} from '@utils/user'; import type UserModel from '@typings/database/models/servers/user'; type AtMentionItemProps = { FooterComponent?: ReactNode; - user: UserProfile | UserModel; + user?: UserProfile | UserModel; containerStyle?: StyleProp; currentUserId: string; includeMargin?: boolean; @@ -115,13 +115,12 @@ const UserItem = ({ const bot = user ? isBot(user) : false; const guest = user ? isGuest(user.roles) : false; const shared = user ? isShared(user) : false; + const deactivated = user ? isDeactivated(user) : false; const isCurrentUser = currentUserId === user?.id; const customStatus = getUserCustomStatus(user); const customStatusExpired = isCustomStatusExpired(user); - const deleteAt = 'deleteAt' in user ? user.deleteAt : user.delete_at; - let displayName = displayUsername(user, locale, teammateNameDisplay); const showTeammateDisplay = displayName !== user?.username; if (isCurrentUser) { @@ -142,11 +141,15 @@ const UserItem = ({ }, [disabled, padding, includeMargin]); const onPress = useCallback(() => { - onUserPress?.(user); + if (user) { + onUserPress?.(user); + } }, [user, onUserPress]); const onLongPress = useCallback(() => { - onUserLongPress?.(user); + if (user) { + onUserLongPress?.(user); + } }, [user, onUserLongPress]); return ( @@ -175,15 +178,15 @@ const UserItem = ({ testID={`${userItemTestId}.display_name`} > {nonBreakingString(displayName)} - {Boolean(showTeammateDisplay) && ( + {Boolean(showTeammateDisplay) && Boolean(user?.username) && ( - {nonBreakingString(` @${user!.username}`)} + {nonBreakingString(` @${user?.username}`)} )} - {Boolean(deleteAt) && ( + {deactivated && ( { +const Reactor = ({channelId, location, reaction, user}: Props) => { const intl = useIntl(); const theme = useTheme(); + const serverUrl = useServerUrl(); const openUserProfile = async () => { if (user) { await dismissBottomSheet(Screens.REACTIONS); @@ -34,6 +39,12 @@ const Reactor = ({channelId, location, user}: Props) => { } }; + useEffect(() => { + if (!user) { + fetchUsersByIds(serverUrl, [reaction.userId]); + } + }, []); + return ( = 0; i--) {