Merge pull request #179 from SimonBrandner/disable-spell-check

Fix disabling spellchecker
This commit is contained in:
J. Ryan Stinnett 2021-04-07 12:07:50 +01:00 committed by GitHub
commit ce26e7964d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -419,17 +419,25 @@ ipcMain.on('ipcCall', async function(ev, payload) {
break; break;
case 'setSpellCheckLanguages': case 'setSpellCheckLanguages':
if (args[0] && args[0].length > 0) { if (args[0] && args[0].length > 0) {
mainWindow.webContents.session.setSpellCheckerEnabled(true);
store.set("spellCheckerEnabled", true);
try { try {
mainWindow.webContents.session.setSpellCheckerLanguages(args[0]); 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 { } else {
mainWindow.webContents.session.setSpellCheckerLanguages([]); mainWindow.webContents.session.setSpellCheckerEnabled(false);
store.set("spellCheckerEnabled", false);
} }
break; break;
case 'getSpellCheckLanguages': case 'getSpellCheckLanguages':
if (store.get("spellCheckerEnabled", true)) {
ret = mainWindow.webContents.session.getSpellCheckerLanguages(); ret = mainWindow.webContents.session.getSpellCheckerLanguages();
} else {
ret = [];
}
break; break;
case 'getAvailableSpellCheckLanguages': case 'getAvailableSpellCheckLanguages':
ret = mainWindow.webContents.session.availableSpellCheckerLanguages; ret = mainWindow.webContents.session.availableSpellCheckerLanguages;
@ -929,12 +937,15 @@ app.on('ready', async () => {
enableRemoteModule: false, enableRemoteModule: false,
contextIsolation: true, contextIsolation: true,
webgl: false, webgl: false,
spellcheck: true,
}, },
}); });
mainWindow.loadURL('vector://vector/webapp/'); mainWindow.loadURL('vector://vector/webapp/');
Menu.setApplicationMenu(vectorMenu); Menu.setApplicationMenu(vectorMenu);
// Handle spellchecker
// For some reason spellCheckerEnabled isn't persisted so we have to use the store here
mainWindow.webContents.session.setSpellCheckerEnabled(store.get("spellCheckerEnabled", true));
// Create trayIcon icon // Create trayIcon icon
if (store.get('minimizeToTray', true)) tray.create(trayConfig); if (store.get('minimizeToTray', true)) tray.create(trayConfig);