Merge pull request #379 from vector-im/SimonBrandner/feat/spell-disable

This commit is contained in:
Šimon Brandner 2022-07-28 10:19:37 +02:00 committed by GitHub
commit b693aee5cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -115,27 +115,27 @@ ipcMain.on('ipcCall', async function(_ev: IpcMainEvent, payload) {
global.mainWindow.webContents.goForward(); global.mainWindow.webContents.goForward();
} }
break; break;
case 'setSpellCheckLanguages': case 'setSpellCheckEnabled':
if (args[0] && args[0].length > 0) { if (typeof args[0] !== 'boolean') return;
global.mainWindow.webContents.session.setSpellCheckerEnabled(true);
global.store.set("spellCheckerEnabled", true);
global.mainWindow.webContents.session.setSpellCheckerEnabled(args[0]);
global.store.set("spellCheckerEnabled", args[0]);
break;
case 'getSpellCheckEnabled':
ret = global.store.get("spellCheckerEnabled", true);
break;
case 'setSpellCheckLanguages':
try { try {
global.mainWindow.webContents.session.setSpellCheckerLanguages(args[0]); global.mainWindow.webContents.session.setSpellCheckerLanguages(args[0]);
} catch (er) { } catch (er) {
console.log("There were problems setting the spellcheck languages", er); console.log("There were problems setting the spellcheck languages", er);
} }
} else {
global.mainWindow.webContents.session.setSpellCheckerEnabled(false);
global.store.set("spellCheckerEnabled", false);
}
break; break;
case 'getSpellCheckLanguages': case 'getSpellCheckLanguages':
if (global.store.get("spellCheckerEnabled", true)) {
ret = global.mainWindow.webContents.session.getSpellCheckerLanguages(); ret = global.mainWindow.webContents.session.getSpellCheckerLanguages();
} else {
ret = [];
}
break; break;
case 'getAvailableSpellCheckLanguages': case 'getAvailableSpellCheckLanguages':
ret = global.mainWindow.webContents.session.availableSpellCheckerLanguages; ret = global.mainWindow.webContents.session.availableSpellCheckerLanguages;