Switch from defer to Promise.withResolvers (#29078)

* Switch from defer to PromiseWithResolvers

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Add modernizr check

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Iterate

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2025-05-08 11:03:43 +01:00
committed by GitHub
parent 0f783ede5e
commit a3f5d207de
34 changed files with 61 additions and 89 deletions

View File

@@ -8,7 +8,6 @@ Please see LICENSE files in the repository root for full details.
import React, { type JSX } from "react";
import { type MatrixEvent, EventType, RelationType, type MatrixClient, MatrixError } from "matrix-js-sdk/src/matrix";
import { defer } from "matrix-js-sdk/src/utils";
import { logger } from "matrix-js-sdk/src/logger";
import { MatrixClientPeg } from "../../../MatrixClientPeg";
@@ -58,7 +57,7 @@ export default class MessageEditHistoryDialog extends React.PureComponent<IProps
const eventId = this.props.mxEvent.getId()!;
const client = MatrixClientPeg.safeGet();
const { resolve, reject, promise } = defer<boolean>();
const { resolve, reject, promise } = Promise.withResolvers<boolean>();
let result: Awaited<ReturnType<MatrixClient["relations"]>>;
try {

View File

@@ -10,7 +10,6 @@ import React, { createRef, type RefObject } from "react";
import classNames from "classnames";
import { flatMap } from "lodash";
import { type Room } from "matrix-js-sdk/src/matrix";
import { defer } from "matrix-js-sdk/src/utils";
import Autocompleter, {
type ICompletion,
@@ -177,7 +176,7 @@ export default class Autocomplete extends React.PureComponent<IProps, IState> {
}
}
const deferred = defer<void>();
const deferred = Promise.withResolvers<void>();
this.setState(
{
completions,

View File

@@ -9,7 +9,6 @@ Please see LICENSE files in the repository root for full details.
import React, { lazy, Suspense, useCallback, useContext, useEffect, useRef, useState } from "react";
import { type MatrixClient } from "matrix-js-sdk/src/matrix";
import { logger } from "matrix-js-sdk/src/logger";
import { defer } from "matrix-js-sdk/src/utils";
import { _t } from "../../../../../languageHandler";
import Modal from "../../../../../Modal";
@@ -98,7 +97,7 @@ const useSignOut = (
const url = getManageDeviceUrl(delegatedAuthAccountUrl, deviceId);
window.open(url, "_blank");
} else {
const deferredSuccess = defer<boolean>();
const deferredSuccess = Promise.withResolvers<boolean>();
await deleteDevicesWithInteractiveAuth(matrixClient, deviceIds, async (success) => {
deferredSuccess.resolve(!!success);
});