signal-desktop/ts/windows/waitForSettingsChange.ts
2021-09-29 11:37:30 -07:00

25 lines
613 B
TypeScript

// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { ipcRenderer as ipc } from 'electron';
import { explodePromise } from '../util/explodePromise';
let preferencesChangeResolvers = new Array<() => void>();
ipc.on('preferences-changed', _event => {
const resolvers = preferencesChangeResolvers;
preferencesChangeResolvers = [];
for (const resolve of resolvers) {
resolve();
}
});
export function waitForSettingsChange(): Promise<void> {
const { promise, resolve } = explodePromise<void>();
preferencesChangeResolvers.push(resolve);
return promise;
}