Skip to content

Commit 1cd86f8

Browse files
committed
PresenceStatusIndicator: Take a user ID instead of email
1 parent 9c6aadd commit 1cd86f8

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/account-info/AccountDetails.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default function AccountDetails(props: Props): Node {
6060
<View style={componentStyles.statusWrapper}>
6161
<PresenceStatusIndicator
6262
style={componentStyles.presenceStatusIndicator}
63-
email={user.email}
63+
userId={user.user_id}
6464
hideIfOffline={false}
6565
useOpaqueBackground={false}
6666
/>

src/common/PresenceStatusIndicator.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import { useSelector } from '../react-redux';
1010
import { statusFromPresenceAndUserStatus } from '../utils/presence';
1111
import { getPresence } from '../selectors';
1212
import { getUserStatus } from '../user-statuses/userStatusesModel';
13-
import { getAllUsersByEmail } from '../users/userSelectors';
13+
import { tryGetUserForId } from '../users/userSelectors';
1414
import { ensureUnreachable } from '../types';
15+
import type { UserId, UserPresence } from '../types';
1516

1617
const styles = createStyleSheet({
1718
common: {
@@ -109,7 +110,7 @@ function PresenceStatusIndicatorUnavailable() {
109110

110111
type Props = $ReadOnly<{|
111112
style?: ViewStyleProp,
112-
email: string,
113+
userId: UserId,
113114
hideIfOffline: boolean,
114115
useOpaqueBackground: boolean,
115116
|}>;
@@ -125,12 +126,10 @@ type Props = $ReadOnly<{|
125126
* @prop hideIfOffline - Do not render for 'offline' state.
126127
*/
127128
export default function PresenceStatusIndicator(props: Props): Node {
128-
const { email, style, hideIfOffline, useOpaqueBackground } = props;
129+
const { userId, style, hideIfOffline, useOpaqueBackground } = props;
129130
const presence = useSelector(getPresence);
130-
const allUsersByEmail = useSelector(getAllUsersByEmail);
131-
132-
const userPresence = presence[email];
133-
const user = allUsersByEmail.get(email);
131+
const user = useSelector(state => tryGetUserForId(state, userId));
132+
const userPresence = (user && (presence[user.email]: UserPresence | void)) ?? null;
134133

135134
const userStatus = useSelector(state => user && getUserStatus(state, user.user_id));
136135

src/common/UserAvatarWithPresence.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default function UserAvatarWithPresence(props: Props): Node {
4848
<UserAvatar avatarUrl={user.avatar_url} size={size} isMuted={isMuted} onPress={onPress}>
4949
<PresenceStatusIndicator
5050
style={styles.status}
51-
email={user.email}
51+
userId={user.user_id}
5252
hideIfOffline
5353
useOpaqueBackground
5454
/>

0 commit comments

Comments
 (0)