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

Commit 1f8fbc8

Browse files
authored
Don't allow group calls to be unterminated (#9710)
If group calls can be unterminated, this makes it very difficult to determine the duration of past calls. This was also causing duplicate event tiles to be rendered if multiple people tried to terminate a call simultaneously.
1 parent 8576601 commit 1f8fbc8

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/events/EventTileFactory.tsx

+3-6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { MatrixEvent } from "matrix-js-sdk/src/models/event";
1919
import { EventType, MsgType, RelationType } from "matrix-js-sdk/src/@types/event";
2020
import { M_POLL_START, Optional } from "matrix-events-sdk";
2121
import { MatrixClient } from "matrix-js-sdk/src/client";
22+
import { GroupCallIntent } from "matrix-js-sdk/src/webrtc/groupCall";
2223

2324
import EditorStateTransfer from "../utils/EditorStateTransfer";
2425
import { RoomPermalinkCreator } from "../utils/permalinks/Permalinks";
@@ -412,13 +413,9 @@ export function haveRendererForEvent(mxEvent: MatrixEvent, showHiddenEvents: boo
412413
return Boolean(mxEvent.getContent()['predecessor']);
413414
} else if (ElementCall.CALL_EVENT_TYPE.names.some(eventType => handler === STATE_EVENT_TILE_TYPES.get(eventType))) {
414415
const intent = mxEvent.getContent()['m.intent'];
415-
const prevContent = mxEvent.getPrevContent();
416-
// If the call became unterminated or previously had invalid contents,
417-
// then this event marks the start of the call
418-
const newlyStarted = 'm.terminated' in prevContent
419-
|| !('m.intent' in prevContent) || !('m.type' in prevContent);
416+
const newlyStarted = Object.keys(mxEvent.getPrevContent()).length === 0;
420417
// Only interested in events that mark the start of a non-room call
421-
return typeof intent === 'string' && intent !== 'm.room' && newlyStarted;
418+
return newlyStarted && typeof intent === 'string' && intent !== GroupCallIntent.Room;
422419
} else if (handler === JSONEventFactory) {
423420
return false;
424421
} else {

0 commit comments

Comments
 (0)