[MM-20794] change suggestion on spellchecker locale change (#1132)

* [MM-20794] change suggestions if locale is changed

* prevent crash on spellchecker load
This commit is contained in:
Guillermo Vayá
2019-12-16 15:59:47 +01:00
committed by GitHub
parent 69af5a1f96
commit 75b47a95b7
2 changed files with 16 additions and 9 deletions

View File

@@ -133,6 +133,7 @@ function teamConfigChange(updatedTeams) {
function handleSelectSpellCheckerLocale(locale) {
config.set('spellCheckerLocale', locale);
ipcRenderer.send('update-dict', locale);
}
ReactDOM.render(

View File

@@ -776,16 +776,22 @@ function handleUpdateMenuEvent(event, configData) {
}
}
function handleUpdateDictionaryEvent() {
// localeSelected might be null, if that's the case, use config's locale
function handleUpdateDictionaryEvent(_, localeSelected) {
if (config.useSpellChecker) {
spellChecker = new SpellChecker(
config.spellCheckerLocale,
path.resolve(app.getAppPath(), 'node_modules/simple-spellchecker/dict'),
(err) => {
if (err) {
console.error(err);
}
});
const locale = localeSelected || config.spellCheckerLocale;
try {
spellChecker = new SpellChecker(
locale,
path.resolve(app.getAppPath(), 'node_modules/simple-spellchecker/dict'),
(err) => {
if (err) {
console.error(err);
}
});
} catch (e) {
console.error('couldn\'t load a spellchecker for locale');
}
}
}