aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/spellchecker
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2018-12-02 00:21:13 +0100
committerLibravatar Stefan Malzner <stefan@adlk.io>2018-12-02 00:21:13 +0100
commitd70ad5f7f278babab9f017e17eac9e5e9fe8ec5d (patch)
tree9f132b171e99cf1e30c103b6c099dfa346005be5 /src/features/spellchecker
parentfix(Windows): Fix impossible Ctrl+10 Shortcut (diff)
downloadferdium-app-d70ad5f7f278babab9f017e17eac9e5e9fe8ec5d.tar.gz
ferdium-app-d70ad5f7f278babab9f017e17eac9e5e9fe8ec5d.tar.zst
ferdium-app-d70ad5f7f278babab9f017e17eac9e5e9fe8ec5d.zip
Simplify spellchecker feature init
Diffstat (limited to 'src/features/spellchecker')
-rw-r--r--src/features/spellchecker/index.js35
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 @@
1import { autorun, reaction } from 'mobx'; 1import { autorun, observable } from 'mobx';
2 2
3import { DEFAULT_FEATURES_CONFIG } from '../../config'; 3import { DEFAULT_FEATURES_CONFIG } from '../../config';
4 4
5const debug = require('debug')('Franz:feature:spellchecker'); 5const debug = require('debug')('Franz:feature:spellchecker');
6 6
7export const config = { 7export const config = observable({
8 isPremiumFeature: DEFAULT_FEATURES_CONFIG.isSpellcheckerPremiumFeature, 8 isPremiumFeature: DEFAULT_FEATURES_CONFIG.isSpellcheckerPremiumFeature,
9}; 9});
10 10
11export default function init(stores) { 11export 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