feat(monospace): add get/set IPC handlers with safe validation

This commit is contained in:
2026-07-23 09:34:57 +05:30
parent f1c3aaa0ef
commit 65dfdfb307
2 changed files with 86 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
'use strict';
const { ipcMain } = require('electron');
const store = require('../store');
const { safeMonospaceSettings, DEFAULT_SETTINGS } = require('../settings/monospaceSettings');
function readCurrent() {
return {
monospaceFont: store.get('monospaceFont', DEFAULT_SETTINGS.monospaceFont),
monospaceLigatures: store.get('monospaceLigatures', DEFAULT_SETTINGS.monospaceLigatures),
};
}
function register() {
ipcMain.handle('get-monospace-settings', () => readCurrent());
ipcMain.handle('set-monospace-settings', (_event, partial) => {
const safe = safeMonospaceSettings(partial || {});
if (Object.prototype.hasOwnProperty.call(partial || {}, 'monospaceFont')) {
store.set('monospaceFont', safe.monospaceFont);
}
if (Object.prototype.hasOwnProperty.call(partial || {}, 'monospaceLigatures')) {
store.set('monospaceLigatures', safe.monospaceLigatures);
}
return readCurrent();
});
}
module.exports = { register, readCurrent };