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:
@@ -5,7 +5,6 @@ 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 { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
import { type ElectronChannel } from "../../@types/global";
|
||||
@@ -17,7 +16,7 @@ interface IPCPayload {
|
||||
}
|
||||
|
||||
export class IPCManager {
|
||||
private pendingIpcCalls: { [ipcCallId: number]: IDeferred<any> } = {};
|
||||
private pendingIpcCalls: { [ipcCallId: number]: PromiseWithResolvers<any> } = {};
|
||||
private nextIpcCallId = 0;
|
||||
|
||||
public constructor(
|
||||
@@ -33,7 +32,7 @@ export class IPCManager {
|
||||
public async call(name: string, ...args: any[]): Promise<any> {
|
||||
// TODO this should be moved into the preload.js file.
|
||||
const ipcCallId = ++this.nextIpcCallId;
|
||||
const deferred = defer<any>();
|
||||
const deferred = Promise.withResolvers<any>();
|
||||
this.pendingIpcCalls[ipcCallId] = deferred;
|
||||
// Maybe add a timeout to these? Probably not necessary.
|
||||
window.electron!.send(this.sendChannel, { id: ipcCallId, name, args });
|
||||
|
||||
Reference in New Issue
Block a user