forked from Ivasoft/mattermost-mobile
fix: crash when reactor is missing (#7448)
This commit is contained in:
@@ -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 Props = {
|
||||
FooterComponent?: ReactNode;
|
||||
user: UserProfile | UserModel;
|
||||
user?: UserProfile | UserModel;
|
||||
containerStyle?: StyleProp<ViewStyle>;
|
||||
currentUserId: string;
|
||||
includeMargin?: boolean;
|
||||
@@ -117,13 +117,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) {
|
||||
@@ -144,11 +143,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 (
|
||||
@@ -177,15 +180,15 @@ const UserItem = ({
|
||||
testID={`${userItemTestId}.display_name`}
|
||||
>
|
||||
{nonBreakingString(displayName)}
|
||||
{Boolean(showTeammateDisplay) && (
|
||||
{Boolean(showTeammateDisplay) && Boolean(user?.username) && (
|
||||
<Text
|
||||
style={style.rowUsername}
|
||||
testID={`${userItemTestId}.username`}
|
||||
>
|
||||
{nonBreakingString(` @${user!.username}`)}
|
||||
{nonBreakingString(` @${user?.username}`)}
|
||||
</Text>
|
||||
)}
|
||||
{Boolean(deleteAt) && (
|
||||
{deactivated && (
|
||||
<Text
|
||||
style={style.rowUsername}
|
||||
testID={`${userItemTestId}.deactivated`}
|
||||
|
||||
Reference in New Issue
Block a user