Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 860764c

Browse files
authored
Use new matrixRTC calling (#11792)
* initial Signed-off-by: Timo K <[email protected]> * cleanup1 Signed-off-by: Timo K <[email protected]> * bring back call timer Signed-off-by: Timo K <[email protected]> * more cleanup and test removals Signed-off-by: Timo K <[email protected]> * remove event Signed-off-by: Timo K <[email protected]> * cleanups and minor fixes Signed-off-by: Timo K <[email protected]> * add matrixRTC to stubClient Signed-off-by: Timo K <[email protected]> * update tests (some got removed) The removal is a consequence of EW now doing less call logic. More logic is done by the js sdk (MatrixRTCSession) And therefore in EC itself. Signed-off-by: Timo K <[email protected]> * cleanups Signed-off-by: Timo K <[email protected]> * mock the session Signed-off-by: Timo K <[email protected]> * lint Signed-off-by: Timo K <[email protected]> * remove GroupCallDuration Signed-off-by: Timo K <[email protected]> * review and fixing tests Signed-off-by: Timo K <[email protected]> --------- Signed-off-by: Timo K <[email protected]>
1 parent c4852dd commit 860764c

File tree

13 files changed

+176
-255
lines changed

13 files changed

+176
-255
lines changed

src/components/views/beacon/RoomCallBanner.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ limitations under the License.
1515
*/
1616

1717
import React, { useCallback } from "react";
18-
import { EventType, Room } from "matrix-js-sdk/src/matrix";
18+
import { Room } from "matrix-js-sdk/src/matrix";
1919
import { logger } from "matrix-js-sdk/src/logger";
2020

2121
import { _t } from "../../../languageHandler";
@@ -27,7 +27,7 @@ import { ConnectionState, ElementCall } from "../../../models/Call";
2727
import { useCall } from "../../../hooks/useCall";
2828
import { useEventEmitterState } from "../../../hooks/useEventEmitter";
2929
import { OwnBeaconStore, OwnBeaconStoreEvent } from "../../../stores/OwnBeaconStore";
30-
import { GroupCallDuration } from "../voip/CallDuration";
30+
import { SessionDuration } from "../voip/CallDuration";
3131
import { SdkContextClass } from "../../../contexts/SDKContext";
3232

3333
interface RoomCallBannerProps {
@@ -49,12 +49,13 @@ const RoomCallBannerInner: React.FC<RoomCallBannerProps> = ({ roomId, call }) =>
4949
[roomId],
5050
);
5151

52+
// TODO matrix rtc
5253
const onClick = useCallback(() => {
53-
const event = call.groupCall.room.currentState.getStateEvents(
54-
EventType.GroupCallPrefix,
55-
call.groupCall.groupCallId,
56-
);
57-
if (event === null) {
54+
logger.log("clicking on the call banner is not supported anymore - there are no timeline events anymore.");
55+
let messageLikeEventId: string | undefined;
56+
if (!messageLikeEventId) {
57+
// Until we have a timeline event for calls this will always be true.
58+
// We will never jump to the non existing timeline event.
5859
logger.error("Couldn't find a group call event to jump to");
5960
return;
6061
}
@@ -63,17 +64,17 @@ const RoomCallBannerInner: React.FC<RoomCallBannerProps> = ({ roomId, call }) =>
6364
action: Action.ViewRoom,
6465
room_id: roomId,
6566
metricsTrigger: undefined,
66-
event_id: event.getId(),
67+
event_id: messageLikeEventId,
6768
scroll_into_view: true,
6869
highlighted: true,
6970
});
70-
}, [call, roomId]);
71+
}, [roomId]);
7172

7273
return (
7374
<div className="mx_RoomCallBanner" onClick={onClick}>
7475
<div className="mx_RoomCallBanner_text">
7576
<span className="mx_RoomCallBanner_label">{_t("voip|video_call")}</span>
76-
<GroupCallDuration groupCall={call.groupCall} />
77+
<SessionDuration session={call.session} />
7778
</div>
7879

7980
<AccessibleButton onClick={connect} kind="primary" element="button" disabled={false}>

src/components/views/messages/CallEvent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import MemberAvatar from "../avatars/MemberAvatar";
3333
import { LiveContentSummary, LiveContentType } from "../rooms/LiveContentSummary";
3434
import FacePile from "../elements/FacePile";
3535
import MatrixClientContext from "../../../contexts/MatrixClientContext";
36-
import { CallDuration, GroupCallDuration } from "../voip/CallDuration";
36+
import { CallDuration, SessionDuration } from "../voip/CallDuration";
3737
import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
3838

3939
const MAX_FACES = 8;
@@ -77,7 +77,7 @@ const ActiveCallEvent = forwardRef<any, ActiveCallEventProps>(
7777
/>
7878
<FacePile members={facePileMembers} size="24px" overflow={facePileOverflow} />
7979
</div>
80-
{call && <GroupCallDuration groupCall={call.groupCall} />}
80+
{call && <SessionDuration session={call.session} />}
8181
<AccessibleTooltipButton
8282
className="mx_CallEvent_button"
8383
kind={buttonKind}

src/components/views/rooms/LegacyRoomHeader.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ import IconizedContextMenu, {
6565
IconizedContextMenuRadio,
6666
} from "../context_menus/IconizedContextMenu";
6767
import { ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload";
68-
import { GroupCallDuration } from "../voip/CallDuration";
68+
import { SessionDuration } from "../voip/CallDuration";
6969
import { Alignment } from "../elements/Tooltip";
7070
import RoomCallBanner from "../beacon/RoomCallBanner";
7171
import { shouldShowComponent } from "../../../customisations/helpers/UIComponents";
@@ -787,7 +787,7 @@ export default class RoomHeader extends React.Component<IProps, IState> {
787787
{icon}
788788
{name}
789789
{this.props.activeCall instanceof ElementCall && (
790-
<GroupCallDuration groupCall={this.props.activeCall.groupCall} />
790+
<SessionDuration session={this.props.activeCall?.session} />
791791
)}
792792
{/* Empty topic element to fill out space */}
793793
<div className="mx_LegacyRoomHeader_topic" />

src/components/views/voip/CallDuration.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ limitations under the License.
1515
*/
1616

1717
import React, { FC, useState, useEffect, memo } from "react";
18-
import { GroupCall } from "matrix-js-sdk/src/matrix";
18+
// eslint-disable-next-line no-restricted-imports
19+
import { MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession";
1920

2021
import { formatPreciseDuration } from "../../../DateUtils";
2122

@@ -32,20 +33,25 @@ export const CallDuration: FC<CallDurationProps> = memo(({ delta }) => {
3233
return <div className="mx_CallDuration">{formatPreciseDuration(delta)}</div>;
3334
});
3435

35-
interface GroupCallDurationProps {
36-
groupCall: GroupCall;
36+
interface SessionDurationProps {
37+
session: MatrixRTCSession | undefined;
3738
}
3839

3940
/**
40-
* A call duration counter that automatically counts up, given a live GroupCall
41+
* A call duration counter that automatically counts up, given a matrixRTC session
4142
* object.
4243
*/
43-
export const GroupCallDuration: FC<GroupCallDurationProps> = ({ groupCall }) => {
44+
export const SessionDuration: FC<SessionDurationProps> = ({ session }) => {
4445
const [now, setNow] = useState(() => Date.now());
46+
4547
useEffect(() => {
4648
const timer = window.setInterval(() => setNow(Date.now()), 1000);
4749
return () => clearInterval(timer);
4850
}, []);
4951

50-
return groupCall.creationTs === null ? null : <CallDuration delta={now - groupCall.creationTs} />;
52+
// This is a temporal solution.
53+
// Using the oldest membership will update when this user leaves.
54+
// This implies that the displayed call duration will also update consequently.
55+
const createdTs = session?.getOldestMembership()?.createdTs();
56+
return createdTs ? <CallDuration delta={now - createdTs} /> : <CallDuration delta={0} />;
5157
};

0 commit comments

Comments
 (0)