Avoid creating multiple call objects for the same widget (#30839)

* Extract some setup code out of the call tests

* Don't force all rooms to be rechecked for calls when starting a call

* Remove misleading unused group call callbacks

The GroupCallEventHandler hasn't been relevant to our Element Call group calls for some time; instead we look at the state of the MatrixRTCSessionManager and WidgetStore to determine whether a call has been started.

* Avoid creating multiple call objects for the same widget

* fix test

---------

Co-authored-by: Will Hunt <will@half-shot.uk>
This commit is contained in:
Robin
2025-09-23 11:45:48 -04:00
committed by GitHub
parent c8d937655b
commit b5d8e63c6d
6 changed files with 162 additions and 107 deletions

View File

@@ -38,7 +38,6 @@ import { WidgetMessagingStore, WidgetMessagingStoreEvent } from "../stores/widge
import ActiveWidgetStore, { ActiveWidgetStoreEvent } from "../stores/ActiveWidgetStore";
import { getCurrentLanguage } from "../languageHandler";
import { Anonymity, PosthogAnalytics } from "../PosthogAnalytics";
import { UPDATE_EVENT } from "../stores/AsyncStore";
import { isVideoRoom } from "../utils/video-rooms";
import { FontWatcher } from "../settings/watchers/FontWatcher";
import { type JitsiCallMemberContent, JitsiCallMemberEventType } from "../call-types";
@@ -702,7 +701,7 @@ export class ElementCall extends Call {
// To use Element Call without touching room state, we create a virtual
// widget (one that doesn't have a corresponding state event)
const url = ElementCall.generateWidgetUrl(client, roomId);
const createdWidget = WidgetStore.instance.addVirtualWidget(
return WidgetStore.instance.addVirtualWidget(
{
id: secureRandomString(24), // So that it's globally unique
creatorUserId: client.getUserId()!,
@@ -722,8 +721,6 @@ export class ElementCall extends Call {
},
roomId,
);
WidgetStore.instance.emit(UPDATE_EVENT, null);
return createdWidget;
}
private static getWidgetData(