From 0cdc165ace53019371fc126d8d76817f1f2ed027 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Fri, 7 Dec 2018 13:47:00 +0100 Subject: fix(Spellchecker): Dictionaries are now part of app instead of dynamic download --- src/stores/DictionaryStore.js | 45 ------------------------------------------- src/stores/index.js | 2 -- 2 files changed, 47 deletions(-) delete mode 100644 src/stores/DictionaryStore.js (limited to 'src/stores') diff --git a/src/stores/DictionaryStore.js b/src/stores/DictionaryStore.js deleted file mode 100644 index b9c5f2abf..000000000 --- a/src/stores/DictionaryStore.js +++ /dev/null @@ -1,45 +0,0 @@ -import { observable } from 'mobx'; -import { createDownloader } from 'hunspell-dict-downloader'; - -import Store from './lib/Store'; - -import { DICTIONARY_PATH } from '../config'; - -const debug = require('debug')('Franz:DictionaryStore'); - -export default class DictionaryStore extends Store { - @observable available = [] - @observable installed = [] - - _dictDownloader = null - - constructor(...args) { - super(...args); - - this.registerReactions([ - this._downloadDictForUserLocale.bind(this), - ]); - } - - async setup() { - this._dictDownloader = await createDownloader(DICTIONARY_PATH); - debug('dicts', this._dictDownloader); - - this.available = this._dictDownloader.availableDictionaries; - this.installed = this._dictDownloader.installedDictionaries; - - if (!this.installed.includes('en-us')) { - this._dictDownloader.installDictionary('en-us'); - } - } - - _downloadDictForUserLocale() { - const spellcheckerLanguage = this.stores.settings.app.spellcheckerLanguage; - - debug('trying to Downloading dict for', spellcheckerLanguage); - if (!this.installed.includes(spellcheckerLanguage) && this.available.includes(spellcheckerLanguage) && spellcheckerLanguage !== 'en-us') { - debug('Downloading dict for', spellcheckerLanguage); - this._dictDownloader.installDictionary(spellcheckerLanguage); - } - } -} diff --git a/src/stores/index.js b/src/stores/index.js index f547d0a7a..96b844c95 100644 --- a/src/stores/index.js +++ b/src/stores/index.js @@ -9,7 +9,6 @@ import UIStore from './UIStore'; import PaymentStore from './PaymentStore'; import NewsStore from './NewsStore'; import RequestStore from './RequestStore'; -import DictionaryStore from './DictionaryStore'; import GlobalErrorStore from './GlobalErrorStore'; export default (api, actions, router) => { @@ -27,7 +26,6 @@ export default (api, actions, router) => { payment: new PaymentStore(stores, api, actions), news: new NewsStore(stores, api, actions), requests: new RequestStore(stores, api, actions), - dictionary: new DictionaryStore(stores, api, actions), globalError: new GlobalErrorStore(stores, api, actions), }); // Initialize all stores -- cgit v1.2.3-70-g09d2