@@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
66Please see LICENSE files in the repository root for full details.
77*/
88
9- import React , { type JSX , useCallback , useEffect , useRef , useState , useId } from "react" ;
9+ import React , { type JSX , type ReactNode , useCallback , useEffect , useRef , useState , useId } from "react" ;
1010import {
1111 type Room ,
1212 type MatrixEvent ,
@@ -15,7 +15,7 @@ import {
1515 EventType ,
1616 MatrixEventEvent ,
1717} from "matrix-js-sdk/src/matrix" ;
18- import { Button , Form , Heading , InlineField , Label , ToggleInput , Tooltip } from "@vector-im/compound-web" ;
18+ import { AvatarStack , Button , Form , Heading , InlineField , Label , ToggleInput , Tooltip } from "@vector-im/compound-web" ;
1919import { logger } from "matrix-js-sdk/src/logger" ;
2020import { type IRTCNotificationContent } from "matrix-js-sdk/src/matrixrtc" ;
2121import {
@@ -34,8 +34,7 @@ import defaultDispatcher from "../dispatcher/dispatcher";
3434import { type ViewRoomPayload } from "../dispatcher/payloads/ViewRoomPayload" ;
3535import { Action } from "../dispatcher/actions" ;
3636import ToastStore from "../stores/ToastStore" ;
37- import { LiveContentSummary , LiveContentType } from "../components/views/rooms/LiveContentSummary" ;
38- import { useCall , useParticipantCount } from "../hooks/useCall" ;
37+ import { useCall , useParticipatingMembers } from "../hooks/useCall" ;
3938import AccessibleButton , { type ButtonEvent } from "../components/views/elements/AccessibleButton" ;
4039import { useDispatcher } from "../hooks/useDispatcher" ;
4140import { type ActionPayload } from "../dispatcher/payloads" ;
@@ -44,6 +43,7 @@ import LegacyCallHandler, { AudioID } from "../LegacyCallHandler";
4443import { useEventEmitter , useTypedEventEmitter } from "../hooks/useEventEmitter" ;
4544import { CallStore , CallStoreEvent } from "../stores/CallStore" ;
4645import DMRoomMap from "../utils/DMRoomMap" ;
46+ import MemberAvatar from "../components/views/avatars/MemberAvatar" ;
4747
4848/**
4949 * Get the key for the incoming call toast. A combination of the call ID and room ID.
@@ -279,19 +279,30 @@ export function IncomingCallToast({ notificationEvent, toastKey }: Props): JSX.E
279279 useEventEmitter ( CallStore . instance , CallStoreEvent . Call , onCall ) ;
280280 useEventEmitter ( call ?? undefined , CallEvent . Participants , onParticipantChange ) ;
281281 useEventEmitter ( room , RoomEvent . Timeline , onTimelineChange ) ;
282+
282283 const otherUserId = DMRoomMap . shared ( ) . getUserIdForRoomId ( roomId ) ;
283- const participantCount = useParticipantCount ( call ) ;
284- const detailsInformation =
285- notificationContent . notification_type === "ring" ? (
286- < span > { otherUserId } </ span >
287- ) : (
288- < LiveContentSummary
289- type = { isVoice ? LiveContentType . Voice : LiveContentType . Video }
290- text = { isVoice ? _t ( "common|voice" ) : _t ( "common|video" ) }
291- active = { false }
292- participantCount = { participantCount }
293- />
294- ) ;
284+ const members = useParticipatingMembers ( call ) ;
285+ const avatars = ( ) : ReactNode => (
286+ < AvatarStack className = "mx_IncomingCallToast_avatars" >
287+ { members . slice ( 0 , 3 ) . map ( ( m ) => (
288+ < MemberAvatar key = { m . userId } size = "20px" member = { m } aria-label = { m . name } />
289+ ) ) }
290+ </ AvatarStack >
291+ ) ;
292+
293+ let detailsInformation : ReactNode ;
294+ if ( notificationContent . notification_type === "ring" ) {
295+ detailsInformation = < span > { otherUserId } </ span > ;
296+ } else if ( members . length > 0 ) {
297+ detailsInformation =
298+ members . length > 3
299+ ? _t (
300+ "voip|call_members|overflow" ,
301+ { count : members . length , overflowCount : members . length - 3 } ,
302+ { avatars } ,
303+ )
304+ : _t ( "voip|call_members|exhaustive" , { count : members . length } , { avatars } ) ;
305+ }
295306
296307 const Icon = isVoice ? VoiceCallSolidIcon : VideoCallSolidIcon ;
297308 const iconLabel = isVoice ? _t ( "voip|voice_call" ) : _t ( "voip|video_call" ) ;
0 commit comments