diff --git a/apps/web/src/@types/global.d.ts b/apps/web/src/@types/global.d.ts index b65d95d3b5..e3e49fad70 100644 --- a/apps/web/src/@types/global.d.ts +++ b/apps/web/src/@types/global.d.ts @@ -21,7 +21,6 @@ import { type ModalManager } from "../Modal"; import type SettingsStore from "../settings/SettingsStore"; import type RightPanelStore from "../stores/right-panel/RightPanelStore"; import type WidgetStore from "../stores/WidgetStore"; -import type LegacyCallHandler from "../LegacyCallHandler"; import type UserActivity from "../UserActivity"; import { type ModalWidgetStore } from "../stores/ModalWidgetStore"; import { type WidgetLayoutStore } from "../stores/widgets/WidgetLayoutStore"; @@ -99,7 +98,6 @@ declare global { mxRightPanelStore: RightPanelStore; mxWidgetStore: WidgetStore; mxWidgetLayoutStore: WidgetLayoutStore; - mxLegacyCallHandler: LegacyCallHandler; mxUserActivity: UserActivity; mxModalWidgetStore: ModalWidgetStore; mxSpaceStore: SpaceStoreClass; diff --git a/apps/web/src/LegacyCallHandler.tsx b/apps/web/src/LegacyCallHandler.tsx index 3ccf500b26..48627d59ad 100644 --- a/apps/web/src/LegacyCallHandler.tsx +++ b/apps/web/src/LegacyCallHandler.tsx @@ -34,7 +34,6 @@ import { WidgetType } from "./widgets/WidgetType"; import { SettingLevel } from "./settings/SettingLevel"; import QuestionDialog from "./components/views/dialogs/QuestionDialog"; import ErrorDialog from "./components/views/dialogs/ErrorDialog"; -import WidgetStore from "./stores/WidgetStore"; import { WidgetMessagingStore } from "./stores/widgets/WidgetMessagingStore"; import { ElementWidgetActions } from "./stores/widgets/ElementWidgetActions"; import { UIFeature } from "./settings/UIFeature"; @@ -42,7 +41,6 @@ import { Action } from "./dispatcher/actions"; import { addManagedHybridWidget, isManagedHybridWidgetEnabled } from "./widgets/ManagedHybrid"; import SdkConfig from "./SdkConfig"; import { ensureDMExists } from "./createRoom"; -import { WidgetLayoutStore } from "./stores/widgets/WidgetLayoutStore"; import IncomingLegacyCallToast, { getIncomingLegacyCallToastKey } from "./toasts/IncomingLegacyCallToast"; import ToastStore from "./stores/ToastStore"; import { type ViewRoomPayload } from "./dispatcher/payloads/ViewRoomPayload"; @@ -54,41 +52,13 @@ import { localNotificationsAreSilenced } from "./utils/notifications"; import { isNotNull } from "./Typeguards"; import { BackgroundAudio } from "./audio/BackgroundAudio"; import { Jitsi } from "./widgets/Jitsi.ts"; +import { type SDKContextClass } from "./contexts/SDKContextClass.ts"; export const PROTOCOL_PSTN = "m.protocol.pstn"; export const PROTOCOL_PSTN_PREFIXED = "im.vector.protocol.pstn"; const CHECK_PROTOCOLS_ATTEMPTS = 3; -type MediaEventType = keyof HTMLMediaElementEventMap; -const MEDIA_ERROR_EVENT_TYPES: MediaEventType[] = [ - "error", - // The media has become empty; for example, this event is sent if the media has - // already been loaded (or partially loaded), and the HTMLMediaElement.load method - // is called to reload it. - "emptied", - // The user agent is trying to fetch media data, but data is unexpectedly not - // forthcoming. - "stalled", - // Media data loading has been suspended. - "suspend", - // Playback has stopped because of a temporary lack of data - "waiting", -]; -const MEDIA_DEBUG_EVENT_TYPES: MediaEventType[] = [ - "play", - "pause", - "playing", - "ended", - "loadeddata", - "loadedmetadata", - "canplay", - "canplaythrough", - "volumechange", -]; - -const MEDIA_EVENT_TYPES = [...MEDIA_ERROR_EVENT_TYPES, ...MEDIA_DEBUG_EVENT_TYPES]; - export enum AudioID { Ring = "ringAudio", Ringback = "ringbackAudio", @@ -96,13 +66,6 @@ export enum AudioID { Busy = "busyAudio", } -/* istanbul ignore next */ -const debuglog = (...args: any[]): void => { - if (SettingsStore.getValue("debug_legacy_call_handler")) { - logger.log.call(console, "LegacyCallHandler debuglog:", ...args); - } -}; - interface ThirdpartyLookupResponse { userid: string; protocol: string; @@ -151,12 +114,8 @@ export default class LegacyCallHandler extends TypedEventEmitter = {}; // Record them for stopping - public static get instance(): LegacyCallHandler { - if (!window.mxLegacyCallHandler) { - window.mxLegacyCallHandler = new LegacyCallHandler(); - } - - return window.mxLegacyCallHandler; + public constructor(private readonly sdkContext: SDKContextClass) { + super(); } /* @@ -193,18 +152,6 @@ export default class LegacyCallHandler extends TypedEventEmitter`, e); - } else if (MEDIA_EVENT_TYPES.includes(e.type as MediaEventType)) { - debuglog(`encountered "${e.type}" event with