@@ -18,14 +18,13 @@ import React, { forwardRef, useCallback, useContext, useMemo } from "react";
18
18
19
19
import type { MatrixEvent } from "matrix-js-sdk/src/models/event" ;
20
20
import type { RoomMember } from "matrix-js-sdk/src/models/room-member" ;
21
- import { Call , ConnectionState } from "../../../models/Call" ;
21
+ import { ConnectionState , ElementCall } from "../../../models/Call" ;
22
22
import { _t } from "../../../languageHandler" ;
23
23
import {
24
24
useCall ,
25
25
useConnectionState ,
26
- useJoinCallButtonDisabled ,
27
- useJoinCallButtonTooltip ,
28
- useParticipants ,
26
+ useJoinCallButtonDisabledTooltip ,
27
+ useParticipatingMembers ,
29
28
} from "../../../hooks/useCall" ;
30
29
import defaultDispatcher from "../../../dispatcher/dispatcher" ;
31
30
import type { ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload" ;
@@ -35,38 +34,38 @@ import MemberAvatar from "../avatars/MemberAvatar";
35
34
import { LiveContentSummary , LiveContentType } from "../rooms/LiveContentSummary" ;
36
35
import FacePile from "../elements/FacePile" ;
37
36
import MatrixClientContext from "../../../contexts/MatrixClientContext" ;
38
- import { CallDuration , CallDurationFromEvent } from "../voip/CallDuration" ;
37
+ import { CallDuration , GroupCallDuration } from "../voip/CallDuration" ;
39
38
import AccessibleTooltipButton from "../elements/AccessibleTooltipButton" ;
40
39
41
40
const MAX_FACES = 8 ;
42
41
43
42
interface ActiveCallEventProps {
44
43
mxEvent : MatrixEvent ;
45
- participants : Set < RoomMember > ;
44
+ call : ElementCall | null ;
45
+ participatingMembers : RoomMember [ ] ;
46
46
buttonText : string ;
47
47
buttonKind : string ;
48
- buttonTooltip ?: string ;
49
- buttonDisabled ?: boolean ;
48
+ buttonDisabledTooltip ?: string ;
50
49
onButtonClick : ( ( ev : ButtonEvent ) => void ) | null ;
51
50
}
52
51
53
52
const ActiveCallEvent = forwardRef < any , ActiveCallEventProps > (
54
53
(
55
54
{
56
55
mxEvent,
57
- participants,
56
+ call,
57
+ participatingMembers,
58
58
buttonText,
59
59
buttonKind,
60
- buttonDisabled,
61
- buttonTooltip,
60
+ buttonDisabledTooltip,
62
61
onButtonClick,
63
62
} ,
64
63
ref ,
65
64
) => {
66
65
const senderName = useMemo ( ( ) => mxEvent . sender ?. name ?? mxEvent . getSender ( ) , [ mxEvent ] ) ;
67
66
68
- const facePileMembers = useMemo ( ( ) => [ ... participants ] . slice ( 0 , MAX_FACES ) , [ participants ] ) ;
69
- const facePileOverflow = participants . size > facePileMembers . length ;
67
+ const facePileMembers = useMemo ( ( ) => participatingMembers . slice ( 0 , MAX_FACES ) , [ participatingMembers ] ) ;
68
+ const facePileOverflow = participatingMembers . length > facePileMembers . length ;
70
69
71
70
return < div className = "mx_CallEvent_wrapper" ref = { ref } >
72
71
< div className = "mx_CallEvent mx_CallEvent_active" >
@@ -85,17 +84,17 @@ const ActiveCallEvent = forwardRef<any, ActiveCallEventProps>(
85
84
type = { LiveContentType . Video }
86
85
text = { _t ( "Video call" ) }
87
86
active = { false }
88
- participantCount = { participants . size }
87
+ participantCount = { participatingMembers . length }
89
88
/>
90
89
< FacePile members = { facePileMembers } faceSize = { 24 } overflow = { facePileOverflow } />
91
90
</ div >
92
- < CallDurationFromEvent mxEvent = { mxEvent } />
91
+ { call && < GroupCallDuration groupCall = { call . groupCall } /> }
93
92
< AccessibleTooltipButton
94
93
className = "mx_CallEvent_button"
95
94
kind = { buttonKind }
96
- disabled = { onButtonClick === null || buttonDisabled }
95
+ disabled = { onButtonClick === null || buttonDisabledTooltip !== undefined }
97
96
onClick = { onButtonClick }
98
- tooltip = { buttonTooltip }
97
+ tooltip = { buttonDisabledTooltip }
99
98
>
100
99
{ buttonText }
101
100
</ AccessibleTooltipButton >
@@ -106,14 +105,13 @@ const ActiveCallEvent = forwardRef<any, ActiveCallEventProps>(
106
105
107
106
interface ActiveLoadedCallEventProps {
108
107
mxEvent : MatrixEvent ;
109
- call : Call ;
108
+ call : ElementCall ;
110
109
}
111
110
112
111
const ActiveLoadedCallEvent = forwardRef < any , ActiveLoadedCallEventProps > ( ( { mxEvent, call } , ref ) => {
113
112
const connectionState = useConnectionState ( call ) ;
114
- const participants = useParticipants ( call ) ;
115
- const joinCallButtonTooltip = useJoinCallButtonTooltip ( call ) ;
116
- const joinCallButtonDisabled = useJoinCallButtonDisabled ( call ) ;
113
+ const participatingMembers = useParticipatingMembers ( call ) ;
114
+ const joinCallButtonDisabledTooltip = useJoinCallButtonDisabledTooltip ( call ) ;
117
115
118
116
const connect = useCallback ( ( ev : ButtonEvent ) => {
119
117
ev . preventDefault ( ) ;
@@ -142,11 +140,11 @@ const ActiveLoadedCallEvent = forwardRef<any, ActiveLoadedCallEventProps>(({ mxE
142
140
return < ActiveCallEvent
143
141
ref = { ref }
144
142
mxEvent = { mxEvent }
145
- participants = { participants }
143
+ call = { call }
144
+ participatingMembers = { participatingMembers }
146
145
buttonText = { buttonText }
147
146
buttonKind = { buttonKind }
148
- buttonDisabled = { joinCallButtonDisabled }
149
- buttonTooltip = { joinCallButtonTooltip }
147
+ buttonDisabledTooltip = { joinCallButtonDisabledTooltip ?? undefined }
150
148
onButtonClick = { onButtonClick }
151
149
/> ;
152
150
} ) ;
@@ -159,7 +157,6 @@ interface CallEventProps {
159
157
* An event tile representing an active or historical Element call.
160
158
*/
161
159
export const CallEvent = forwardRef < any , CallEventProps > ( ( { mxEvent } , ref ) => {
162
- const noParticipants = useMemo ( ( ) => new Set < RoomMember > ( ) , [ ] ) ;
163
160
const client = useContext ( MatrixClientContext ) ;
164
161
const call = useCall ( mxEvent . getRoomId ( ) ! ) ;
165
162
const latestEvent = client . getRoom ( mxEvent . getRoomId ( ) ) ! . currentState
@@ -180,12 +177,13 @@ export const CallEvent = forwardRef<any, CallEventProps>(({ mxEvent }, ref) => {
180
177
return < ActiveCallEvent
181
178
ref = { ref }
182
179
mxEvent = { mxEvent }
183
- participants = { noParticipants }
180
+ call = { null }
181
+ participatingMembers = { [ ] }
184
182
buttonText = { _t ( "Join" ) }
185
183
buttonKind = "primary"
186
184
onButtonClick = { null }
187
185
/> ;
188
186
}
189
187
190
- return < ActiveLoadedCallEvent mxEvent = { mxEvent } call = { call } ref = { ref } /> ;
188
+ return < ActiveLoadedCallEvent mxEvent = { mxEvent } call = { call as ElementCall } ref = { ref } /> ;
191
189
} ) ;
0 commit comments