Skip to content

Commit 3d5471f

Browse files
committed
fix: consider display avatar pref in video conf message
1 parent c8c8eaa commit 3d5471f

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,8 +1,10 @@
11
import { VideoConferenceStatus } from '@rocket.chat/core-typings';
22
import {
33
useGoToRoom,
4+
useSetting,
45
useTranslation,
56
useUserId,
7+
useUserPreference,
68
} from '@rocket.chat/ui-contexts';
79
import type * as UiKit from '@rocket.chat/ui-kit';
810
import {
@@ -39,6 +41,8 @@ const VideoConferenceBlock = ({
3941
const surfaceType = useSurfaceType();
4042
const userId = useUserId();
4143
const goToRoom = useGoToRoom();
44+
const displayAvatars = useUserPreference<boolean>('displayAvatars');
45+
const showRealName = useSetting<boolean>('UI_Use_Real_Name');
4246

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

@@ -147,13 +151,19 @@ const VideoConferenceBlock = ({
147151
{data.type !== 'direct' &&
148152
(data.users.length ? (
149153
<>
150-
<VideoConfMessageUserStack users={data.users} />
154+
<VideoConfMessageUserStack
155+
displayAvatars={displayAvatars}
156+
showRealName={showRealName}
157+
users={data.users}
158+
/>
151159
<VideoConfMessageFooterText>
152-
{data.users.length > MAX_USERS
160+
{data.users.length > MAX_USERS || !displayAvatars
153161
? t('__usersCount__member_joined', {
154-
usersCount: data.users.length - MAX_USERS,
162+
count: displayAvatars
163+
? data.users.length - MAX_USERS
164+
: data.users.length,
155165
})
156-
: t('joined')}
166+
: t('Joined')}
157167
</VideoConfMessageFooterText>
158168
</>
159169
) : (
@@ -205,13 +215,19 @@ const VideoConferenceBlock = ({
205215
</VideoConfMessageButton>
206216
{Boolean(data.users.length) && (
207217
<>
208-
<VideoConfMessageUserStack users={data.users} />
218+
<VideoConfMessageUserStack
219+
displayAvatars={displayAvatars}
220+
showRealName={showRealName}
221+
users={data.users}
222+
/>
209223
<VideoConfMessageFooterText>
210-
{data.users.length > MAX_USERS
224+
{data.users.length > MAX_USERS || !displayAvatars
211225
? t('__usersCount__member_joined', {
212-
count: data.users.length - MAX_USERS,
226+
count: displayAvatars
227+
? data.users.length - MAX_USERS
228+
: data.users.length,
213229
})
214-
: t('joined')}
230+
: t('Joined')}
215231
</VideoConfMessageFooterText>
216232
</>
217233
)}

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,22 @@ export const CallEnded: StoryFn<typeof VideoConfMessage> = () => (
119119
);
120120

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

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 { memo, type ReactElement } 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)