diff options
author | Stefan Malzner <stefan@adlk.io> | 2018-12-07 13:47:00 +0100 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2018-12-07 13:47:00 +0100 |
commit | 0cdc165ace53019371fc126d8d76817f1f2ed027 (patch) | |
tree | 1c98c3e31258c29ff2f49b748b9df16a892f66e6 /src/stores | |
parent | Bump version to b20 (diff) | |
download | ferdium-app-0cdc165ace53019371fc126d8d76817f1f2ed027.tar.gz ferdium-app-0cdc165ace53019371fc126d8d76817f1f2ed027.tar.zst ferdium-app-0cdc165ace53019371fc126d8d76817f1f2ed027.zip |
fix(Spellchecker): Dictionaries are now part of app instead of dynamic download
Diffstat (limited to 'src/stores')
-rw-r--r-- | src/stores/DictionaryStore.js | 45 | ||||
-rw-r--r-- | src/stores/index.js | 2 |
2 files changed, 0 insertions, 47 deletions
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 @@ | |||
1 | import { observable } from 'mobx'; | ||
2 | import { createDownloader } from 'hunspell-dict-downloader'; | ||
3 | |||
4 | import Store from './lib/Store'; | ||
5 | |||
6 | import { DICTIONARY_PATH } from '../config'; | ||
7 | |||
8 | const debug = require('debug')('Franz:DictionaryStore'); | ||
9 | |||
10 | export default class DictionaryStore extends Store { | ||
11 | @observable available = [] | ||
12 | @observable installed = [] | ||
13 | |||
14 | _dictDownloader = null | ||
15 | |||
16 | constructor(...args) { | ||
17 | super(...args); | ||
18 | |||
19 | this.registerReactions([ | ||
20 | this._downloadDictForUserLocale.bind(this), | ||
21 | ]); | ||
22 | } | ||
23 | |||
24 | async setup() { | ||
25 | this._dictDownloader = await createDownloader(DICTIONARY_PATH); | ||
26 | debug('dicts', this._dictDownloader); | ||
27 | |||
28 | this.available = this._dictDownloader.availableDictionaries; | ||
29 | this.installed = this._dictDownloader.installedDictionaries; | ||
30 | |||
31 | if (!this.installed.includes('en-us')) { | ||
32 | this._dictDownloader.installDictionary('en-us'); | ||
33 | } | ||
34 | } | ||
35 | |||
36 | _downloadDictForUserLocale() { | ||
37 | const spellcheckerLanguage = this.stores.settings.app.spellcheckerLanguage; | ||
38 | |||
39 | debug('trying to Downloading dict for', spellcheckerLanguage); | ||
40 | if (!this.installed.includes(spellcheckerLanguage) && this.available.includes(spellcheckerLanguage) && spellcheckerLanguage !== 'en-us') { | ||
41 | debug('Downloading dict for', spellcheckerLanguage); | ||
42 | this._dictDownloader.installDictionary(spellcheckerLanguage); | ||
43 | } | ||
44 | } | ||
45 | } | ||
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'; | |||
9 | import PaymentStore from './PaymentStore'; | 9 | import PaymentStore from './PaymentStore'; |
10 | import NewsStore from './NewsStore'; | 10 | import NewsStore from './NewsStore'; |
11 | import RequestStore from './RequestStore'; | 11 | import RequestStore from './RequestStore'; |
12 | import DictionaryStore from './DictionaryStore'; | ||
13 | import GlobalErrorStore from './GlobalErrorStore'; | 12 | import GlobalErrorStore from './GlobalErrorStore'; |
14 | 13 | ||
15 | export default (api, actions, router) => { | 14 | export default (api, actions, router) => { |
@@ -27,7 +26,6 @@ export default (api, actions, router) => { | |||
27 | payment: new PaymentStore(stores, api, actions), | 26 | payment: new PaymentStore(stores, api, actions), |
28 | news: new NewsStore(stores, api, actions), | 27 | news: new NewsStore(stores, api, actions), |
29 | requests: new RequestStore(stores, api, actions), | 28 | requests: new RequestStore(stores, api, actions), |
30 | dictionary: new DictionaryStore(stores, api, actions), | ||
31 | globalError: new GlobalErrorStore(stores, api, actions), | 29 | globalError: new GlobalErrorStore(stores, api, actions), |
32 | }); | 30 | }); |
33 | // Initialize all stores | 31 | // Initialize all stores |