Skip to content

Commit 9c6aadd

Browse files
committed
UserAvatarWithPresence: Don't ask caller to specify isMuted
Instead, grab that information from Redux inside this component. This actually fixes a few spots where we were failing to show an avatar as muted: - The lightbox header, where it shows the message sender - The ChatScreen header for a 1:1 PM - The list of selected users in the user picker (UserPickerCard)
1 parent 5b04f58 commit 9c6aadd

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

src/common/UserAvatarWithPresence.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import UserAvatar from './UserAvatar';
88
import PresenceStatusIndicator from './PresenceStatusIndicator';
99
import { tryGetUserForId } from '../users/userSelectors';
1010
import { useSelector } from '../react-redux';
11+
import { getMutedUsers } from '../directSelectors';
1112

1213
const styles = createStyleSheet({
1314
status: {
@@ -21,7 +22,6 @@ type Props = $ReadOnly<{|
2122
userId: UserId,
2223
size: number,
2324
onPress?: () => void,
24-
isMuted?: boolean,
2525
|}>;
2626

2727
/**
@@ -32,9 +32,11 @@ type Props = $ReadOnly<{|
3232
* @prop [onPress]
3333
*/
3434
export default function UserAvatarWithPresence(props: Props): Node {
35-
const { userId, isMuted, size, onPress } = props;
35+
const { userId, size, onPress } = props;
3636

3737
const user = useSelector(state => tryGetUserForId(state, userId));
38+
const isMuted = useSelector(getMutedUsers).has(userId);
39+
3840
if (!user) {
3941
// This condition really does happen, because UserItem can be passed a fake
4042
// pseudo-user by PeopleAutocomplete, to represent `@all` or `@everyone`.

src/title/TitleGroup.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { Node } from 'react';
55
import { View } from 'react-native';
66

77
import { useSelector } from '../react-redux';
8-
import { getMutedUsers, getOwnUserId } from '../selectors';
8+
import { getOwnUserId } from '../selectors';
99
import { pmUiRecipientsFromKeyRecipients, type PmKeyRecipients } from '../utils/recipient';
1010
import styles, { createStyleSheet } from '../styles';
1111
import UserAvatarWithPresence from '../common/UserAvatarWithPresence';
@@ -23,7 +23,6 @@ const componentStyles = createStyleSheet({
2323

2424
export default function TitleGroup(props: Props): Node {
2525
const { recipients } = props;
26-
const mutedUsers = useSelector(getMutedUsers);
2726
const ownUserId = useSelector(getOwnUserId);
2827
const userIds = pmUiRecipientsFromKeyRecipients(recipients, ownUserId);
2928
const navigation = useNavigation();
@@ -38,7 +37,6 @@ export default function TitleGroup(props: Props): Node {
3837
}}
3938
size={32}
4039
userId={userId}
41-
isMuted={mutedUsers.has(userId)}
4240
/>
4341
</View>
4442
))}

src/users/UserItem.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ export function UserItemRaw<
100100
// At size medium, keep just big enough for a 48px touch target.
101101
size={size === 'large' ? 48 : 32}
102102
userId={user.user_id}
103-
isMuted={isMuted}
104103
onPress={onPress && handlePress}
105104
/>
106105
<View style={styles.textWrapper}>

0 commit comments

Comments
 (0)