Skip to content

Commit

Permalink
CustomProfileFields: Use styled UserItem for (unknown user)
Browse files Browse the repository at this point in the history
Since zulip#5790 last month, UserItem has been prepared to gracefully
handle users we don't know about. Use that, instead of
special-casing with a plain ZulipTextIntl, which we'd been doing
since 2022-06 (0a10831) when CustomProfileFields was added.

The change won't be visible unless a given user object is actually
absent; that'll start happening when we do zulip#5808.

See screenshots:
  zulip#5809 (comment)
  • Loading branch information
chrisbobbe committed Jan 4, 2024
1 parent ecfd8d4 commit 930d9d7
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions src/account-info/CustomProfileFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,21 @@ import { View } from 'react-native';
import { type UserOrBot, type UserId } from '../api/modelTypes';
import WebLink from '../common/WebLink';
import ZulipText from '../common/ZulipText';
import ZulipTextIntl from '../common/ZulipTextIntl';
import { ensureUnreachable } from '../generics';
import { useSelector } from '../react-redux';
import { tryGetUserForId } from '../selectors';
import {
type CustomProfileFieldValue,
getCustomProfileFieldsForUser,
} from '../users/userSelectors';
import UserItem from '../users/UserItem';
import { useNavigation } from '../react-navigation';

/* eslint-disable no-shadow */

type Props = {|
+user: UserOrBot,
|};

function CustomProfileFieldUser(props: {| +userId: UserId |}): React.Node {
const { userId } = props;
const user = useSelector(state => tryGetUserForId(state, userId));

const navigation = useNavigation();
const onPress = React.useCallback(
Expand All @@ -34,10 +29,6 @@ function CustomProfileFieldUser(props: {| +userId: UserId |}): React.Node {
[navigation],
);

if (!user) {
return <ZulipTextIntl text="(unknown user)" />;
}

return <UserItem userId={userId} onPress={onPress} size="medium" />;
}

Expand Down

0 comments on commit 930d9d7

Please sign in to comment.