diff options
Diffstat (limited to 'src/features/spellchecker/index.js')
-rw-r--r-- | src/features/spellchecker/index.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/features/spellchecker/index.js b/src/features/spellchecker/index.js new file mode 100644 index 000000000..63506103c --- /dev/null +++ b/src/features/spellchecker/index.js | |||
@@ -0,0 +1,27 @@ | |||
1 | import { autorun, observable } from 'mobx'; | ||
2 | |||
3 | import { DEFAULT_FEATURES_CONFIG } from '../../config'; | ||
4 | |||
5 | const debug = require('debug')('Franz:feature:spellchecker'); | ||
6 | |||
7 | export const config = observable({ | ||
8 | isPremiumFeature: DEFAULT_FEATURES_CONFIG.isSpellcheckerPremiumFeature, | ||
9 | }); | ||
10 | |||
11 | export default function init(stores) { | ||
12 | debug('Initializing `spellchecker` feature'); | ||
13 | |||
14 | autorun(() => { | ||
15 | const { isSpellcheckerPremiumFeature } = stores.features.features; | ||
16 | |||
17 | config.isPremiumFeature = isSpellcheckerPremiumFeature !== undefined ? isSpellcheckerPremiumFeature : DEFAULT_FEATURES_CONFIG.isSpellcheckerPremiumFeature; | ||
18 | |||
19 | if (!stores.user.data.isPremium && config.isPremiumFeature && stores.settings.app.enableSpellchecking) { | ||
20 | debug('Override settings.spellcheckerEnabled flag to false'); | ||
21 | |||
22 | Object.assign(stores.settings.app, { | ||
23 | enableSpellchecking: false, | ||
24 | }); | ||
25 | } | ||
26 | }); | ||
27 | } | ||