[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) { function handleSelectSpellCheckerLocale(locale) {
config.set('spellCheckerLocale', locale); config.set('spellCheckerLocale', locale);
ipcRenderer.send('update-dict', locale);
} }
ReactDOM.render( 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) { if (config.useSpellChecker) {
spellChecker = new SpellChecker( const locale = localeSelected || config.spellCheckerLocale;
config.spellCheckerLocale, try {
path.resolve(app.getAppPath(), 'node_modules/simple-spellchecker/dict'), spellChecker = new SpellChecker(
(err) => { locale,
if (err) { path.resolve(app.getAppPath(), 'node_modules/simple-spellchecker/dict'),
console.error(err); (err) => {
} if (err) {
}); console.error(err);
}
});
} catch (e) {
console.error('couldn\'t load a spellchecker for locale');
}
} }
} }