Fix settings corrupting
This commit is contained in:
parent
7ce37f858c
commit
78deb0ebad
@ -23,12 +23,18 @@ function readSettings() {
|
|||||||
|
|
||||||
ipcMain.handle(IpcEvents.GET_SETTINGS_DIR, () => SETTINGS_DIR);
|
ipcMain.handle(IpcEvents.GET_SETTINGS_DIR, () => SETTINGS_DIR);
|
||||||
ipcMain.handle(IpcEvents.GET_QUICK_CSS, () => readCss());
|
ipcMain.handle(IpcEvents.GET_QUICK_CSS, () => readCss());
|
||||||
// .on because we need Settings synchronously (ipcRenderer.sendSync)
|
|
||||||
ipcMain.on(IpcEvents.GET_SETTINGS, (e) => e.returnValue = readSettings());
|
|
||||||
ipcMain.handle(IpcEvents.SET_SETTINGS, (_, s) => void writeFile(SETTINGS_FILE, s));
|
|
||||||
ipcMain.handle(IpcEvents.OPEN_PATH, (_, path) => shell.openPath(path));
|
ipcMain.handle(IpcEvents.OPEN_PATH, (_, path) => shell.openPath(path));
|
||||||
ipcMain.handle(IpcEvents.OPEN_EXTERNAL, (_, url) => shell.openExternal(url));
|
ipcMain.handle(IpcEvents.OPEN_EXTERNAL, (_, url) => shell.openExternal(url));
|
||||||
|
|
||||||
|
// .on because we need Settings synchronously (ipcRenderer.sendSync)
|
||||||
|
ipcMain.on(IpcEvents.GET_SETTINGS, (e) => e.returnValue = readSettings());
|
||||||
|
|
||||||
|
// This is required because otherwise calling SET_SETTINGS in quick succession may lead to concurrent writes
|
||||||
|
let settingsWriteQueue = Promise.resolve();
|
||||||
|
ipcMain.handle(IpcEvents.SET_SETTINGS, (_, s) => {
|
||||||
|
settingsWriteQueue = settingsWriteQueue.then(() => writeFile(SETTINGS_FILE, s));
|
||||||
|
});
|
||||||
|
|
||||||
export function initIpc(mainWindow: BrowserWindow) {
|
export function initIpc(mainWindow: BrowserWindow) {
|
||||||
open(QUICKCSS_PATH, "a+").then(fd => {
|
open(QUICKCSS_PATH, "a+").then(fd => {
|
||||||
fd.close();
|
fd.close();
|
||||||
|
Loading…
Reference in New Issue
Block a user