diff --git a/src/Modal.tsx b/src/Modal.tsx index cd6c6a3255..e2873783ea 100644 --- a/src/Modal.tsx +++ b/src/Modal.tsx @@ -10,7 +10,6 @@ Please see LICENSE files in the repository root for full details. import React, { StrictMode } from "react"; import { createRoot, type Root } from "react-dom/client"; import classNames from "classnames"; -import { type IDeferred, defer } from "matrix-js-sdk/src/utils"; import { TypedEventEmitter } from "matrix-js-sdk/src/matrix"; import { Glass, TooltipProvider } from "@vector-im/compound-web"; @@ -70,7 +69,7 @@ export interface IModal { /** A deferred to resolve when the dialog closes, with the results as provided by * the call to {@link close} (normally from the `onFinished` callback). */ - deferred?: IDeferred | []>; + deferred?: PromiseWithResolvers | []>; } /** The result of {@link Modal.createDialog}. @@ -254,7 +253,7 @@ export class ModalManager extends TypedEventEmitter(modal: IModal): [IHandle["close"], IHandle["finished"]] { - modal.deferred = defer | []>(); + modal.deferred = Promise.withResolvers | []>(); return [ async (...args: OnFinishedParams): Promise => { if (modal.beforeClosePromise) { diff --git a/src/SlidingSyncManager.ts b/src/SlidingSyncManager.ts index 88b839312d..815e438da7 100644 --- a/src/SlidingSyncManager.ts +++ b/src/SlidingSyncManager.ts @@ -49,7 +49,7 @@ import { SlidingSyncState, } from "matrix-js-sdk/src/sliding-sync"; import { logger } from "matrix-js-sdk/src/logger"; -import { defer, sleep } from "matrix-js-sdk/src/utils"; +import { sleep } from "matrix-js-sdk/src/utils"; // how long to long poll for const SLIDING_SYNC_TIMEOUT_MS = 20 * 1000; @@ -184,7 +184,7 @@ export class SlidingSyncManager { public slidingSync?: SlidingSync; private client?: MatrixClient; - private configureDefer = defer(); + private configureDefer = Promise.withResolvers(); public static get instance(): SlidingSyncManager { return SlidingSyncManager.internalInstance; diff --git a/src/WorkerManager.ts b/src/WorkerManager.ts index a8a95ca727..1d403be88c 100644 --- a/src/WorkerManager.ts +++ b/src/WorkerManager.ts @@ -6,14 +6,12 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com Please see LICENSE files in the repository root for full details. */ -import { defer, type IDeferred } from "matrix-js-sdk/src/utils"; - import { type WorkerPayload } from "./workers/worker"; export class WorkerManager { private readonly worker: Worker; private seq = 0; - private pendingDeferredMap = new Map>(); + private pendingDeferredMap = new Map>(); public constructor(worker: Worker) { this.worker = worker; @@ -30,7 +28,7 @@ export class WorkerManager { public call(request: Request): Promise { const seq = this.seq++; - const deferred = defer(); + const deferred = Promise.withResolvers(); this.pendingDeferredMap.set(seq, deferred); this.worker.postMessage({ seq, ...request }); return deferred.promise; diff --git a/src/audio/Playback.ts b/src/audio/Playback.ts index 58b8a23c22..5247e4836c 100644 --- a/src/audio/Playback.ts +++ b/src/audio/Playback.ts @@ -9,7 +9,6 @@ Please see LICENSE files in the repository root for full details. import EventEmitter from "events"; import { SimpleObservable } from "matrix-widget-api"; import { logger } from "matrix-js-sdk/src/logger"; -import { defer } from "matrix-js-sdk/src/utils"; import { UPDATE_EVENT } from "../stores/AsyncStore"; import { arrayFastResample } from "../utils/arrays"; @@ -158,7 +157,7 @@ export class Playback extends EventEmitter implements IDestroyable, PlaybackInte // 5mb logger.log("Audio file too large: processing through