From 1f8fbc819795b9c19c567b4737109183acf86162 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 5 Dec 2022 11:11:23 -0500 Subject: [PATCH] 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. --- src/events/EventTileFactory.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/events/EventTileFactory.tsx b/src/events/EventTileFactory.tsx index 89bf9cbd73..fb1c822596 100644 --- a/src/events/EventTileFactory.tsx +++ b/src/events/EventTileFactory.tsx @@ -19,6 +19,7 @@ import { MatrixEvent } from "matrix-js-sdk/src/models/event"; import { EventType, MsgType, RelationType } from "matrix-js-sdk/src/@types/event"; import { M_POLL_START, Optional } from "matrix-events-sdk"; import { MatrixClient } from "matrix-js-sdk/src/client"; +import { GroupCallIntent } from "matrix-js-sdk/src/webrtc/groupCall"; import EditorStateTransfer from "../utils/EditorStateTransfer"; import { RoomPermalinkCreator } from "../utils/permalinks/Permalinks"; @@ -412,13 +413,9 @@ export function haveRendererForEvent(mxEvent: MatrixEvent, showHiddenEvents: boo return Boolean(mxEvent.getContent()['predecessor']); } else if (ElementCall.CALL_EVENT_TYPE.names.some(eventType => handler === STATE_EVENT_TILE_TYPES.get(eventType))) { const intent = mxEvent.getContent()['m.intent']; - const prevContent = mxEvent.getPrevContent(); - // If the call became unterminated or previously had invalid contents, - // then this event marks the start of the call - const newlyStarted = 'm.terminated' in prevContent - || !('m.intent' in prevContent) || !('m.type' in prevContent); + const newlyStarted = Object.keys(mxEvent.getPrevContent()).length === 0; // Only interested in events that mark the start of a non-room call - return typeof intent === 'string' && intent !== 'm.room' && newlyStarted; + return newlyStarted && typeof intent === 'string' && intent !== GroupCallIntent.Room; } else if (handler === JSONEventFactory) { return false; } else {