Skip to content

Commit 78fe4d9

Browse files
committed
fix: consider display avatar pref in video conf message
1 parent eaf9c8d commit 78fe4d9

File tree

4 files changed

+63
-18
lines changed

4 files changed

+63
-18
lines changed

packages/fuselage-ui-kit/src/blocks/VideoConferenceBlock/VideoConferenceBlock.tsx

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import {
22
useGoToRoom,
3+
useSetting,
34
useTranslation,
45
useUserId,
6+
useUserPreference,
57
} from '@rocket.chat/ui-contexts';
68
import type * as UiKit from '@rocket.chat/ui-kit';
79
import {
@@ -38,6 +40,8 @@ const VideoConferenceBlock = ({
3840
const surfaceType = useSurfaceType();
3941
const userId = useUserId();
4042
const goToRoom = useGoToRoom();
43+
const displayAvatars = useUserPreference<boolean>('displayAvatars');
44+
const showRealName = useSetting<boolean>('UI_Use_Real_Name');
4145

4246
const { action, viewId = undefined, rid } = useContext(UiKitContext);
4347

@@ -141,13 +145,19 @@ const VideoConferenceBlock = ({
141145
{data.type !== 'direct' &&
142146
(data.users.length ? (
143147
<>
144-
<VideoConfMessageUserStack users={data.users} />
148+
<VideoConfMessageUserStack
149+
displayAvatars={displayAvatars}
150+
showRealName={showRealName}
151+
users={data.users}
152+
/>
145153
<VideoConfMessageFooterText>
146-
{data.users.length > MAX_USERS
154+
{data.users.length > MAX_USERS || !displayAvatars
147155
? t('__usersCount__member_joined', {
148-
usersCount: data.users.length - MAX_USERS,
156+
count: displayAvatars
157+
? data.users.length - MAX_USERS
158+
: data.users.length,
149159
})
150-
: t('joined')}
160+
: t('Joined')}
151161
</VideoConfMessageFooterText>
152162
</>
153163
) : (
@@ -194,13 +204,19 @@ const VideoConferenceBlock = ({
194204
</VideoConfMessageButton>
195205
{Boolean(data.users.length) && (
196206
<>
197-
<VideoConfMessageUserStack users={data.users} />
207+
<VideoConfMessageUserStack
208+
displayAvatars={displayAvatars}
209+
showRealName={showRealName}
210+
users={data.users}
211+
/>
198212
<VideoConfMessageFooterText>
199-
{data.users.length > MAX_USERS
213+
{data.users.length > MAX_USERS || !displayAvatars
200214
? t('__usersCount__member_joined', {
201-
count: data.users.length - MAX_USERS,
215+
count: displayAvatars
216+
? data.users.length - MAX_USERS
217+
: data.users.length,
202218
})
203-
: t('joined')}
219+
: t('Joined')}
204220
</VideoConfMessageFooterText>
205221
</>
206222
)}

packages/ui-video-conf/src/VideoConfMessage/VideoConfMessage.stories.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,23 @@ export const CallEnded: ComponentStory<typeof VideoConfMessage> = () => (
118118
</VideoConfMessage>
119119
);
120120

121+
export const NoAvatars: ComponentStory<typeof VideoConfMessage> = () => (
122+
<VideoConfMessage>
123+
<VideoConfMessageRow>
124+
<VideoConfMessageContent>
125+
<VideoConfMessageIcon variant='outgoing' />
126+
<VideoConfMessageText>Call ongoing</VideoConfMessageText>
127+
</VideoConfMessageContent>
128+
<VideoConfMessageActions>
129+
<VideoConfMessageAction aria-label='info' icon='info' />
130+
</VideoConfMessageActions>
131+
</VideoConfMessageRow>
132+
<VideoConfMessageFooter>
133+
<VideoConfMessageButton primary>Join</VideoConfMessageButton>
134+
<VideoConfMessageUserStack displayAvatars={false} users={Array(3).fill('')} />
135+
<VideoConfMessageFooterText>3 joined</VideoConfMessageFooterText>
136+
</VideoConfMessageFooter>
137+
</VideoConfMessage>
138+
);
139+
121140
export const Loading: ComponentStory<typeof VideoConfMessage> = () => <VideoConfMessageSkeleton />;

packages/ui-video-conf/src/VideoConfMessage/VideoConfMessageFooterText.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { AllHTMLAttributes, ReactElement } from 'react';
44
type VideoConfMessageFooterTextProps = Omit<AllHTMLAttributes<HTMLParagraphElement>, 'is'>;
55

66
const VideoConfMessageFooterText = ({ children, ...props }: VideoConfMessageFooterTextProps): ReactElement => (
7-
<Box {...props} is='p' fontScale='c1' mi={4}>
7+
<Box {...props} is='p' fontScale='micro' mi={4}>
88
{children}
99
</Box>
1010
);

packages/ui-video-conf/src/VideoConfMessage/VideoConfMessageUserStack.tsx

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11
import type { IVideoConferenceUser, Serialized } from '@rocket.chat/core-typings';
2-
import { Avatar, Box } from '@rocket.chat/fuselage';
2+
import { Avatar, Box, Icon } from '@rocket.chat/fuselage';
33
import { useUserAvatarPath } from '@rocket.chat/ui-contexts';
44
import { ReactElement, memo } from 'react';
55

66
const MAX_USERS = 3;
77

8-
const VideoConfMessageUserStack = ({ users }: { users: Serialized<IVideoConferenceUser>[] }): ReactElement => {
8+
type VideoConfMessageUserStackProps = {
9+
users: Serialized<IVideoConferenceUser>[];
10+
displayAvatars?: boolean;
11+
showRealName?: boolean;
12+
};
13+
14+
const VideoConfMessageUserStack = ({ users, showRealName, displayAvatars = true }: VideoConfMessageUserStackProps): ReactElement => {
915
const getUserAvatarPath = useUserAvatarPath();
16+
const usersTooltip = users.map(({ name, username }) => (showRealName ? name : username)).join(', ');
1017

1118
return (
1219
<Box mi={4}>
13-
<Box display='flex' alignItems='center' mi='neg-x2'>
14-
{users.slice(0, MAX_USERS).map(({ username }, index) => (
15-
<Box mi={2} key={index}>
16-
<Avatar size='x28' alt={username || ''} data-tooltip={username} url={getUserAvatarPath(username as string)} />
17-
</Box>
18-
))}
19-
</Box>
20+
{displayAvatars && (
21+
<Box display='flex' alignItems='center' mi='neg-x2'>
22+
{users.slice(0, MAX_USERS).map(({ name, username }, index) => (
23+
<Box mi={2} key={index}>
24+
<Avatar size='x28' alt={username || ''} title={showRealName ? name : username} url={getUserAvatarPath(username as string)} />
25+
</Box>
26+
))}
27+
</Box>
28+
)}
29+
{!displayAvatars && <Icon size='x20' title={usersTooltip} name='user' />}
2030
</Box>
2131
);
2232
};

0 commit comments

Comments
 (0)