aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/spellchecker/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/features/spellchecker/index.js')
-rw-r--r--src/features/spellchecker/index.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/features/spellchecker/index.js b/src/features/spellchecker/index.js
new file mode 100644
index 000000000..2627c9d17
--- /dev/null
+++ b/src/features/spellchecker/index.js
@@ -0,0 +1,54 @@
1import { autorun, reaction } from 'mobx';
2
3const debug = require('debug')('Franz:feature:spellchecker');
4
5const DEFAULT_IS_PREMIUM_FEATURE = true;
6
7export const config = {
8 isPremiumFeature: DEFAULT_IS_PREMIUM_FEATURE,
9};
10
11export default function init(stores) {
12 reaction(
13 () => stores.features.features.needToWaitToProceed,
14 (enabled, r) => {
15 if (enabled) {
16 debug('Initializing `spellchecker` feature');
17
18 // Dispose the reaction to run this only once
19 r.dispose();
20
21 const { isSpellcheckerPremiumFeature } = stores.features.features;
22
23 config.isPremiumFeature = isSpellcheckerPremiumFeature || DEFAULT_IS_PREMIUM_FEATURE;
24
25 // reaction(
26 // () => stores.settings.all.app.enableSpellchecking,
27 // (enabled, r) => {
28 // if (enabled) {
29 // // debug('Initializing `spellchecker` feature');
30
31 // // // Dispose the reaction to run this only once
32 // // r.dispose();
33
34 // // const { isSpellcheckerPremiumFeature } = stores.features.features;
35
36 // // config.isPremiumFeature = isSpellcheckerPremiumFeature || DEFAULT_IS_PREMIUM_FEATURE;
37 // }
38 // },
39 // );
40
41 autorun(() => {
42 if (!stores.user.data.isPremium && config.isPremiumFeature) {
43 debug('Override settings.spellcheckerEnabled flag to false');
44
45 Object.assign(stores.settings.all.app, {
46 enableSpellchecker: false,
47 });
48 }
49 });
50 }
51 },
52 );
53}
54