blob: 8516f816c420456c061508811c98bda3f51769b1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
import { autorun, reaction } from 'mobx';
const debug = require('debug')('Franz:feature:spellchecker');
const DEFAULT_IS_PREMIUM_FEATURE = true;
export const config = {
isPremiumFeature: DEFAULT_IS_PREMIUM_FEATURE,
};
export default function init(stores) {
reaction(
() => stores.features.features.isSpellcheckerPremiumFeature,
(enabled, r) => {
debug('Initializing `spellchecker` feature');
// Dispose the reaction to run this only once
r.dispose();
const { isSpellcheckerPremiumFeature } = stores.features.features;
config.isPremiumFeature = isSpellcheckerPremiumFeature !== undefined ? isSpellcheckerPremiumFeature : DEFAULT_IS_PREMIUM_FEATURE;
autorun(() => {
if (!stores.user.data.isPremium && config.isPremiumFeature) {
debug('Override settings.spellcheckerEnabled flag to false');
Object.assign(stores.settings.all.app, {
enableSpellchecker: false,
});
}
});
},
);
}
|