Skip to content

Commit

Permalink
fix: fallback to userId when name is not set (#1126)
Browse files Browse the repository at this point in the history
Fallback to `participant.userId` when `participant.name` is not set.
  • Loading branch information
oliverlaz authored Oct 4, 2023
1 parent 80f7da9 commit d0a9661
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const Participants = ({
const rootClassName = classnames(styles.participants, className);
const maxDisplayParticipants = participants.slice(0, 3);
const names = maxDisplayParticipants.map(
(participant: any) => participant?.name,
(participant: any) => participant?.name ?? participant.userId,
);
const last = names.pop();

Expand All @@ -143,13 +143,18 @@ export const Participants = ({
<ul className={styles.avatars}>
{maxDisplayParticipants.map((participant: any) => {
return (
<li key={participant?.name} className={styles.participant}>
<li
key={participant?.name ?? participant.userId}
className={styles.participant}
>
<Img
className={styles.avatar}
src={participant?.image}
placeholder={
<div className={styles.placeholder}>
{String(participant?.name)?.charAt(0)}
{String(participant?.name ?? participant.userId)?.charAt(
0,
)}
</div>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ export const ParticipantsControlModal = ({
);

return (
<Panel className={styles.root} title={participant.name}>
<Panel
className={styles.root}
title={participant.name || participant.userId}
>
<ul className={styles.controls}>
{isAudioOn && (
<Restricted requiredGrants={[OwnCapability.MUTE_USERS]}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export const ParticipantListItem = ({
return (
<>
<span className={styles.name}>
{participant?.name} {isLocalParticipant ? '(You)' : null}
{participant?.name || participant?.userId}{' '}
{isLocalParticipant ? '(You)' : null}
</span>
<div className={styles.media}>
<Restricted requiredGrants={[OwnCapability.MUTE_USERS]}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const ParticipantsPanel = ({
const queryRegExp = new RegExp(queryString, 'i');
return Promise.resolve(
(participants || []).filter((participant) => {
return participant.name.match(queryRegExp);
return (participant.name || participant.userId).match(queryRegExp);
}),
);
},
Expand Down Expand Up @@ -116,7 +116,7 @@ export const ParticipantsPanelSmallScreen = ({
const queryRegExp = new RegExp(queryString, 'i');
return Promise.resolve(
(participants || []).filter((participant) => {
return participant.name.match(queryRegExp);
return (participant.name || participant.userId).match(queryRegExp);
}),
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export const useParticipantNotification = () => {

addNotification({
id: uuid(),
message: `${newParticipant.name} has joined the call`,
message: `${
newParticipant.name || newParticipant.userId
} has joined the call`,
icon: <People />,
});
}
Expand All @@ -45,7 +47,9 @@ export const useParticipantNotification = () => {

addNotification({
id: uuid(),
message: `${leavingParticipant.name} has left the call`,
message: `${
leavingParticipant.name || leavingParticipant.userId
} has left the call`,
icon: <People />,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export const useScreenShareNotification = () => {
firstScreenSharingParticipant?.sessionId ===
localParticipant?.sessionId;

const name = isLocal ? 'You' : firstScreenSharingParticipant?.name;
const name = isLocal
? 'You'
: firstScreenSharingParticipant?.name ||
firstScreenSharingParticipant?.userId;
const message = isLocal
? 'You are presenting your screen'
: `${name} is presenting their screen`;
Expand Down

0 comments on commit d0a9661

Please sign in to comment.