diff options
Diffstat (limited to 'src/features')
-rw-r--r-- | src/features/delayApp/index.js | 4 | ||||
-rw-r--r-- | src/features/serviceProxy/index.js | 56 | ||||
-rw-r--r-- | src/features/spellchecker/index.js | 3 |
3 files changed, 59 insertions, 4 deletions
diff --git a/src/features/delayApp/index.js b/src/features/delayApp/index.js index 910b54959..334433df8 100644 --- a/src/features/delayApp/index.js +++ b/src/features/delayApp/index.js | |||
@@ -38,8 +38,8 @@ export default function init(stores) { | |||
38 | let shownAfterLaunch = false; | 38 | let shownAfterLaunch = false; |
39 | let timeLastDelay = moment(); | 39 | let timeLastDelay = moment(); |
40 | 40 | ||
41 | config.delayOffset = globalConfig.delayOffset || DEFAULT_DELAY_OFFSET; | 41 | config.delayOffset = globalConfig.delayOffset !== undefined ? globalConfig.delayOffset : DEFAULT_DELAY_OFFSET; |
42 | config.delayDuration = globalConfig.wait || DEFAULT_DELAY_DURATION; | 42 | config.delayDuration = globalConfig.wait !== undefined ? globalConfig.wait : DEFAULT_DELAY_DURATION; |
43 | 43 | ||
44 | autorun(() => { | 44 | autorun(() => { |
45 | const diff = moment().diff(timeLastDelay); | 45 | const diff = moment().diff(timeLastDelay); |
diff --git a/src/features/serviceProxy/index.js b/src/features/serviceProxy/index.js new file mode 100644 index 000000000..edb1c9367 --- /dev/null +++ b/src/features/serviceProxy/index.js | |||
@@ -0,0 +1,56 @@ | |||
1 | import { autorun, reaction, observable } from 'mobx'; | ||
2 | import { remote } from 'electron'; | ||
3 | |||
4 | const { session } = remote; | ||
5 | |||
6 | const debug = require('debug')('Franz:feature:serviceProxy'); | ||
7 | |||
8 | const DEFAULT_ENABLED = false; | ||
9 | const DEFAULT_IS_PREMIUM = true; | ||
10 | |||
11 | export const config = observable({ | ||
12 | isEnabled: DEFAULT_ENABLED, | ||
13 | isPremium: DEFAULT_IS_PREMIUM, | ||
14 | }); | ||
15 | |||
16 | export default function init(stores) { | ||
17 | reaction( | ||
18 | () => stores.features.features.isServiceProxyEnabled, | ||
19 | (enabled, r) => { | ||
20 | if (enabled) { | ||
21 | debug('Initializing `serviceProxy` feature'); | ||
22 | |||
23 | // Dispose the reaction to run this only once | ||
24 | r.dispose(); | ||
25 | |||
26 | const { isServiceProxyEnabled, isServiceProxyPremiumFeature } = stores.features.features; | ||
27 | |||
28 | config.isEnabled = isServiceProxyEnabled !== undefined ? isServiceProxyEnabled : DEFAULT_ENABLED; | ||
29 | config.isPremium = isServiceProxyPremiumFeature !== undefined ? isServiceProxyPremiumFeature : DEFAULT_IS_PREMIUM; | ||
30 | |||
31 | autorun(() => { | ||
32 | const services = stores.services.all; | ||
33 | const isPremiumUser = stores.user.isPremium; | ||
34 | |||
35 | if (config.isPremium && !isPremiumUser) return; | ||
36 | |||
37 | services.forEach((service) => { | ||
38 | const s = session.fromPartition(`persist:service-${service.id}`); | ||
39 | let proxyHost = 'direct://'; | ||
40 | |||
41 | const serviceProxyConfig = stores.settings.proxy[service.id]; | ||
42 | |||
43 | if (serviceProxyConfig && serviceProxyConfig.isEnabled && serviceProxyConfig.host) { | ||
44 | proxyHost = serviceProxyConfig.host; | ||
45 | } | ||
46 | |||
47 | s.setProxy({ proxyRules: proxyHost }, (e) => { | ||
48 | debug(`Using proxy "${proxyHost}" for "${service.name}" (${service.id})`, e); | ||
49 | }); | ||
50 | }); | ||
51 | }); | ||
52 | } | ||
53 | }, | ||
54 | ); | ||
55 | } | ||
56 | |||
diff --git a/src/features/spellchecker/index.js b/src/features/spellchecker/index.js index 9336f4074..8b3fb7e00 100644 --- a/src/features/spellchecker/index.js +++ b/src/features/spellchecker/index.js | |||
@@ -20,10 +20,9 @@ export default function init(stores) { | |||
20 | 20 | ||
21 | const { isSpellcheckerPremiumFeature } = stores.features.features; | 21 | const { isSpellcheckerPremiumFeature } = stores.features.features; |
22 | 22 | ||
23 | config.isPremiumFeature = isSpellcheckerPremiumFeature || DEFAULT_IS_PREMIUM_FEATURE; | 23 | config.isPremiumFeature = isSpellcheckerPremiumFeature !== undefined ? isSpellcheckerPremiumFeature : DEFAULT_IS_PREMIUM_FEATURE; |
24 | 24 | ||
25 | autorun(() => { | 25 | autorun(() => { |
26 | console.log('FEATURE spellchecker autorun', stores.user.data.isPremium, config.isPremiumFeature); | ||
27 | if (!stores.user.data.isPremium && config.isPremiumFeature) { | 26 | if (!stores.user.data.isPremium && config.isPremiumFeature) { |
28 | debug('Override settings.spellcheckerEnabled flag to false'); | 27 | debug('Override settings.spellcheckerEnabled flag to false'); |
29 | 28 | ||