Cache system-tray-setting in ephemeral config

This commit is contained in:
Fedor Indutny 2021-10-20 12:56:49 -07:00 committed by GitHub
parent 25325622ed
commit 50c9b1bf7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 108 additions and 26 deletions

View file

@ -12,6 +12,11 @@ import {
IPCEventsCallbacksType,
} from '../util/createIPCEvents';
const EPHEMERAL_NAME_MAP = new Map([
['spellCheck', 'spell-check'],
['systemTraySetting', 'system-tray-setting'],
]);
export class SettingsChannel {
private mainWindow?: BrowserWindow;
@ -50,7 +55,9 @@ export class SettingsChannel {
this.installSetting('themeSetting');
this.installSetting('hideMenuBar');
this.installSetting('systemTraySetting');
this.installSetting('systemTraySetting', {
isEphemeral: true,
});
this.installSetting('notificationSetting');
this.installSetting('notificationDrawAttention');
@ -199,8 +206,12 @@ export class SettingsChannel {
ipc.on(`settings:set:${name}`, (event, value) => {
if (isEphemeral) {
strictAssert(name === 'spellCheck', 'Only spellCheck is ephemeral');
ephemeralConfig.set('spell-check', value);
const ephemeralName = EPHEMERAL_NAME_MAP.get(name);
strictAssert(
ephemeralName !== undefined,
`${name} is not an ephemeral setting`
);
ephemeralConfig.set(ephemeralName, value);
}
const { mainWindow } = this;