diff options
author | 2018-12-02 00:21:13 +0100 | |
---|---|---|
committer | 2018-12-02 00:21:13 +0100 | |
commit | d70ad5f7f278babab9f017e17eac9e5e9fe8ec5d (patch) | |
tree | 9f132b171e99cf1e30c103b6c099dfa346005be5 /src/features | |
parent | fix(Windows): Fix impossible Ctrl+10 Shortcut (diff) | |
download | ferdium-app-d70ad5f7f278babab9f017e17eac9e5e9fe8ec5d.tar.gz ferdium-app-d70ad5f7f278babab9f017e17eac9e5e9fe8ec5d.tar.zst ferdium-app-d70ad5f7f278babab9f017e17eac9e5e9fe8ec5d.zip |
Simplify spellchecker feature init
Diffstat (limited to 'src/features')
-rw-r--r-- | src/features/spellchecker/index.js | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/src/features/spellchecker/index.js b/src/features/spellchecker/index.js index 454096e4e..63506103c 100644 --- a/src/features/spellchecker/index.js +++ b/src/features/spellchecker/index.js | |||
@@ -1,36 +1,27 @@ | |||
1 | import { autorun, reaction } from 'mobx'; | 1 | import { autorun, observable } from 'mobx'; |
2 | 2 | ||
3 | import { DEFAULT_FEATURES_CONFIG } from '../../config'; | 3 | import { DEFAULT_FEATURES_CONFIG } from '../../config'; |
4 | 4 | ||
5 | const debug = require('debug')('Franz:feature:spellchecker'); | 5 | const debug = require('debug')('Franz:feature:spellchecker'); |
6 | 6 | ||
7 | export const config = { | 7 | export const config = observable({ |
8 | isPremiumFeature: DEFAULT_FEATURES_CONFIG.isSpellcheckerPremiumFeature, | 8 | isPremiumFeature: DEFAULT_FEATURES_CONFIG.isSpellcheckerPremiumFeature, |
9 | }; | 9 | }); |
10 | 10 | ||
11 | export default function init(stores) { | 11 | export default function init(stores) { |
12 | reaction( | 12 | debug('Initializing `spellchecker` feature'); |
13 | () => stores.features.features.isSpellcheckerPremiumFeature, | ||
14 | (enabled, r) => { | ||
15 | debug('Initializing `spellchecker` feature'); | ||
16 | 13 | ||
17 | // Dispose the reaction to run this only once | 14 | autorun(() => { |
18 | r.dispose(); | 15 | const { isSpellcheckerPremiumFeature } = stores.features.features; |
19 | 16 | ||
20 | const { isSpellcheckerPremiumFeature } = stores.features.features; | 17 | config.isPremiumFeature = isSpellcheckerPremiumFeature !== undefined ? isSpellcheckerPremiumFeature : DEFAULT_FEATURES_CONFIG.isSpellcheckerPremiumFeature; |
21 | 18 | ||
22 | config.isPremiumFeature = isSpellcheckerPremiumFeature !== undefined ? isSpellcheckerPremiumFeature : DEFAULT_FEATURES_CONFIG.isSpellcheckerPremiumFeature; | 19 | if (!stores.user.data.isPremium && config.isPremiumFeature && stores.settings.app.enableSpellchecking) { |
20 | debug('Override settings.spellcheckerEnabled flag to false'); | ||
23 | 21 | ||
24 | autorun(() => { | 22 | Object.assign(stores.settings.app, { |
25 | if (!stores.user.data.isPremium && config.isPremiumFeature) { | 23 | enableSpellchecking: false, |
26 | debug('Override settings.spellcheckerEnabled flag to false'); | ||
27 | |||
28 | Object.assign(stores.settings.all.app, { | ||
29 | enableSpellchecking: false, | ||
30 | }); | ||
31 | } | ||
32 | }); | 24 | }); |
33 | }, | 25 | } |
34 | ); | 26 | }); |
35 | } | 27 | } |
36 | |||