From 97c9378ddcaf581645caafa7fe798c02a1bb77bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sun, 26 Jun 2022 11:43:08 +0200 Subject: [PATCH 1/2] Add new spell check ipc calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/electron-main.ts | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/electron-main.ts b/src/electron-main.ts index 8256c0f..6c9b99a 100644 --- a/src/electron-main.ts +++ b/src/electron-main.ts @@ -499,28 +499,30 @@ ipcMain.on('ipcCall', async function(_ev: IpcMainEvent, payload) { mainWindow.webContents.goForward(); } break; - case 'setSpellCheckLanguages': - if (args[0] && args[0].length > 0) { - mainWindow.webContents.session.setSpellCheckerEnabled(true); - store.set("spellCheckerEnabled", true); + case 'setSpellCheckEnabled': + if (typeof args[0] !== 'boolean') return; - try { - mainWindow.webContents.session.setSpellCheckerLanguages(args[0]); - } catch (er) { - console.log("There were problems setting the spellcheck languages", er); - } - } else { - mainWindow.webContents.session.setSpellCheckerEnabled(false); - store.set("spellCheckerEnabled", false); + mainWindow.webContents.session.setSpellCheckerEnabled(args[0]); + store.set("spellCheckerEnabled", args[0]); + + break; + + case 'getSpellCheckEnabled': + ret = store.get("spellCheckerEnabled", true); + break; + + case 'setSpellCheckLanguages': + try { + mainWindow.webContents.session.setSpellCheckerLanguages(args[0]); + } catch (er) { + console.log("There were problems setting the spellcheck languages", er); } break; + case 'getSpellCheckLanguages': - if (store.get("spellCheckerEnabled", true)) { - ret = mainWindow.webContents.session.getSpellCheckerLanguages(); - } else { - ret = []; - } + ret = mainWindow.webContents.session.getSpellCheckerLanguages(); break; + case 'getAvailableSpellCheckLanguages': ret = mainWindow.webContents.session.availableSpellCheckerLanguages; break; From b48d607d615d6414a920a1be64eaf9dd80f4d922 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 13 Jul 2022 10:29:15 +0100 Subject: [PATCH 2/2] Remove spurious newline --- src/ipc.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ipc.ts b/src/ipc.ts index f46e43d..717a701 100644 --- a/src/ipc.ts +++ b/src/ipc.ts @@ -120,7 +120,6 @@ ipcMain.on('ipcCall', async function(_ev: IpcMainEvent, payload) { global.mainWindow.webContents.session.setSpellCheckerEnabled(args[0]); global.store.set("spellCheckerEnabled", args[0]); - break; case 'getSpellCheckEnabled':