Skip to content

Commit 53a4409

Browse files
daleshortgnprice
authored andcommitted
account-info: Add display of user email to profile
Add prop showEmail to AccountDetails component. When showEmail is true, Account details will attempt to display the user email if available. Tested in iOS simulator 15.2 using using the chat.zulip.org server and the recurse.zulipchat.com server. Fixes: #5400
1 parent 0631bdc commit 53a4409

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

src/account-info/AccountDetails.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import ComponentList from '../common/ComponentList';
1313
import ZulipText from '../common/ZulipText';
1414
import { getUserStatus } from '../user-statuses/userStatusesModel';
1515
import PresenceStatusIndicator from '../common/PresenceStatusIndicator';
16+
import { getDisplayEmailForUser } from '../selectors';
1617

1718
const componentStyles = createStyleSheet({
1819
componentListItem: {
@@ -31,19 +32,25 @@ const componentStyles = createStyleSheet({
3132
statusText: {
3233
textAlign: 'center',
3334
},
35+
boldText: {
36+
fontWeight: 'bold',
37+
},
3438
});
3539

3640
type Props = $ReadOnly<{|
3741
user: UserOrBot,
42+
showEmail: boolean,
3843
|}>;
3944

4045
export default function AccountDetails(props: Props): Node {
41-
const { user } = props;
46+
const { user, showEmail } = props;
4247

4348
const userStatusText = useSelector(state => getUserStatus(state, props.user.user_id).status_text);
4449
const userStatusEmoji = useSelector(
4550
state => getUserStatus(state, props.user.user_id).status_emoji,
4651
);
52+
const realm = useSelector(state => state.realm);
53+
const displayEmail = getDisplayEmailForUser(realm, user);
4754

4855
return (
4956
<ComponentList outerSpacing itemStyle={componentStyles.componentListItem}>
@@ -59,10 +66,19 @@ export default function AccountDetails(props: Props): Node {
5966
/>
6067
<ZulipText
6168
selectable
62-
style={[styles.largerText, styles.halfMarginRight]}
69+
style={[styles.largerText, componentStyles.boldText, styles.halfMarginRight]}
6370
text={user.full_name}
6471
/>
6572
</View>
73+
{displayEmail !== null && showEmail && (
74+
<View>
75+
<ZulipText
76+
selectable
77+
style={[styles.largerText, styles.halfMarginRight]}
78+
text={displayEmail}
79+
/>
80+
</View>
81+
)}
6682
<View style={componentStyles.statusWrapper}>
6783
{userStatusEmoji && (
6884
<Emoji

src/account-info/AccountDetailsScreen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export default function AccountDetailsScreen(props: Props): Node {
7474

7575
return (
7676
<Screen title={title}>
77-
<AccountDetails user={user} />
77+
<AccountDetails user={user} showEmail />
7878
<View style={styles.itemWrapper}>
7979
<ActivityText style={globalStyles.largerText} user={user} />
8080
</View>

src/account-info/ProfileScreen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export default function ProfileScreen(props: Props): Node {
131131
<SafeAreaView mode="padding" edges={['top']} style={{ flex: 1 }}>
132132
<OfflineNoticePlaceholder />
133133
<ScrollView>
134-
<AccountDetails user={ownUser} />
134+
<AccountDetails user={ownUser} showEmail={false} />
135135
<AwayStatusSwitch />
136136
<View style={styles.buttonRow}>
137137
<SetStatusButton />

0 commit comments

Comments
 (0)