diff options
-rw-r--r-- | src/config.js | 11 | ||||
-rw-r--r-- | src/features/delayApp/index.js | 18 | ||||
-rw-r--r-- | src/features/serviceProxy/index.js | 13 | ||||
-rw-r--r-- | src/features/spellchecker/index.js | 8 | ||||
-rw-r--r-- | src/stores/FeaturesStore.js | 6 | ||||
-rw-r--r-- | src/stores/UserStore.js | 8 |
6 files changed, 37 insertions, 27 deletions
diff --git a/src/config.js b/src/config.js index 20cf8a048..08dbb85f3 100644 --- a/src/config.js +++ b/src/config.js | |||
@@ -27,6 +27,17 @@ export const DEFAULT_APP_SETTINGS = { | |||
27 | serviceLimit: 5, | 27 | serviceLimit: 5, |
28 | }; | 28 | }; |
29 | 29 | ||
30 | export const DEFAULT_FEATURES_CONFIG = { | ||
31 | isSpellcheckerPremiumFeature: false, | ||
32 | needToWaitToProceed: false, | ||
33 | needToWaitToProceedConfig: { | ||
34 | delayOffset: 3600000, | ||
35 | wait: 10000, | ||
36 | }, | ||
37 | isServiceProxyEnabled: false, | ||
38 | isServiceProxyPremiumFeature: true, | ||
39 | }; | ||
40 | |||
30 | export const FRANZ_SERVICE_REQUEST = 'hhttp://bit.ly/franz-plugin-docs'; | 41 | export const FRANZ_SERVICE_REQUEST = 'hhttp://bit.ly/franz-plugin-docs'; |
31 | export const FRANZ_TRANSLATION = 'https://bit.ly/franz-translate'; | 42 | export const FRANZ_TRANSLATION = 'https://bit.ly/franz-translate'; |
32 | 43 | ||
diff --git a/src/features/delayApp/index.js b/src/features/delayApp/index.js index 334433df8..3fc0f2570 100644 --- a/src/features/delayApp/index.js +++ b/src/features/delayApp/index.js | |||
@@ -2,19 +2,17 @@ import { autorun, observable, reaction } from 'mobx'; | |||
2 | import moment from 'moment'; | 2 | import moment from 'moment'; |
3 | import DelayAppComponent from './Component'; | 3 | import DelayAppComponent from './Component'; |
4 | 4 | ||
5 | const debug = require('debug')('Franz:feature:delayApp'); | 5 | import { DEFAULT_FEATURES_CONFIG } from '../../config'; |
6 | 6 | ||
7 | const DEFAULT_DELAY_DURATION = 10000; // 10 seconds | 7 | const debug = require('debug')('Franz:feature:delayApp'); |
8 | const DEFAULT_DELAY_OFFSET = 3600000; // 1 hour | ||
9 | const DEFAULT_VISIBILITY = false; | ||
10 | 8 | ||
11 | export const config = { | 9 | export const config = { |
12 | delayOffset: DEFAULT_DELAY_OFFSET, | 10 | delayOffset: DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.delayOffset, |
13 | delayDuration: DEFAULT_DELAY_DURATION, | 11 | delayDuration: DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.wait, |
14 | }; | 12 | }; |
15 | 13 | ||
16 | export const state = observable({ | 14 | export const state = observable({ |
17 | isDelayAppScreenVisible: DEFAULT_VISIBILITY, | 15 | isDelayAppScreenVisible: DEFAULT_FEATURES_CONFIG.needToWaitToProceed, |
18 | }); | 16 | }); |
19 | 17 | ||
20 | function setVisibility(value) { | 18 | function setVisibility(value) { |
@@ -38,8 +36,8 @@ export default function init(stores) { | |||
38 | let shownAfterLaunch = false; | 36 | let shownAfterLaunch = false; |
39 | let timeLastDelay = moment(); | 37 | let timeLastDelay = moment(); |
40 | 38 | ||
41 | config.delayOffset = globalConfig.delayOffset !== undefined ? globalConfig.delayOffset : DEFAULT_DELAY_OFFSET; | 39 | config.delayOffset = globalConfig.delayOffset !== undefined ? globalConfig.delayOffset : DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.delayOffset; |
42 | config.delayDuration = globalConfig.wait !== undefined ? globalConfig.wait : DEFAULT_DELAY_DURATION; | 40 | config.delayDuration = globalConfig.wait !== undefined ? globalConfig.wait : DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.wait; |
43 | 41 | ||
44 | autorun(() => { | 42 | autorun(() => { |
45 | const diff = moment().diff(timeLastDelay); | 43 | const diff = moment().diff(timeLastDelay); |
@@ -55,7 +53,7 @@ export default function init(stores) { | |||
55 | debug('Resetting app delay'); | 53 | debug('Resetting app delay'); |
56 | 54 | ||
57 | setVisibility(false); | 55 | setVisibility(false); |
58 | }, DEFAULT_DELAY_DURATION + 1000); // timer needs to be able to hit 0 | 56 | }, DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.wait + 1000); // timer needs to be able to hit 0 |
59 | } | 57 | } |
60 | }); | 58 | }); |
61 | } | 59 | } |
diff --git a/src/features/serviceProxy/index.js b/src/features/serviceProxy/index.js index edb1c9367..50dea8c9b 100644 --- a/src/features/serviceProxy/index.js +++ b/src/features/serviceProxy/index.js | |||
@@ -1,16 +1,15 @@ | |||
1 | import { autorun, reaction, observable } from 'mobx'; | 1 | import { autorun, reaction, observable } from 'mobx'; |
2 | import { remote } from 'electron'; | 2 | import { remote } from 'electron'; |
3 | 3 | ||
4 | import { DEFAULT_FEATURES_CONFIG } from '../../config'; | ||
5 | |||
4 | const { session } = remote; | 6 | const { session } = remote; |
5 | 7 | ||
6 | const debug = require('debug')('Franz:feature:serviceProxy'); | 8 | const debug = require('debug')('Franz:feature:serviceProxy'); |
7 | 9 | ||
8 | const DEFAULT_ENABLED = false; | ||
9 | const DEFAULT_IS_PREMIUM = true; | ||
10 | |||
11 | export const config = observable({ | 10 | export const config = observable({ |
12 | isEnabled: DEFAULT_ENABLED, | 11 | isEnabled: DEFAULT_FEATURES_CONFIG.isServiceProxyEnabled, |
13 | isPremium: DEFAULT_IS_PREMIUM, | 12 | isPremium: DEFAULT_FEATURES_CONFIG.isServiceProxyPremiumFeature, |
14 | }); | 13 | }); |
15 | 14 | ||
16 | export default function init(stores) { | 15 | export default function init(stores) { |
@@ -25,8 +24,8 @@ export default function init(stores) { | |||
25 | 24 | ||
26 | const { isServiceProxyEnabled, isServiceProxyPremiumFeature } = stores.features.features; | 25 | const { isServiceProxyEnabled, isServiceProxyPremiumFeature } = stores.features.features; |
27 | 26 | ||
28 | config.isEnabled = isServiceProxyEnabled !== undefined ? isServiceProxyEnabled : DEFAULT_ENABLED; | 27 | config.isEnabled = isServiceProxyEnabled !== undefined ? isServiceProxyEnabled : DEFAULT_FEATURES_CONFIG.isServiceProxyEnabled; |
29 | config.isPremium = isServiceProxyPremiumFeature !== undefined ? isServiceProxyPremiumFeature : DEFAULT_IS_PREMIUM; | 28 | config.isPremium = isServiceProxyPremiumFeature !== undefined ? isServiceProxyPremiumFeature : DEFAULT_FEATURES_CONFIG.isServiceProxyPremiumFeature; |
30 | 29 | ||
31 | autorun(() => { | 30 | autorun(() => { |
32 | const services = stores.services.all; | 31 | const services = stores.services.all; |
diff --git a/src/features/spellchecker/index.js b/src/features/spellchecker/index.js index 9bffc1949..454096e4e 100644 --- a/src/features/spellchecker/index.js +++ b/src/features/spellchecker/index.js | |||
@@ -1,11 +1,11 @@ | |||
1 | import { autorun, reaction } from 'mobx'; | 1 | import { autorun, reaction } from 'mobx'; |
2 | 2 | ||
3 | const debug = require('debug')('Franz:feature:spellchecker'); | 3 | import { DEFAULT_FEATURES_CONFIG } from '../../config'; |
4 | 4 | ||
5 | const DEFAULT_IS_PREMIUM_FEATURE = true; | 5 | const debug = require('debug')('Franz:feature:spellchecker'); |
6 | 6 | ||
7 | export const config = { | 7 | export const config = { |
8 | isPremiumFeature: DEFAULT_IS_PREMIUM_FEATURE, | 8 | isPremiumFeature: DEFAULT_FEATURES_CONFIG.isSpellcheckerPremiumFeature, |
9 | }; | 9 | }; |
10 | 10 | ||
11 | export default function init(stores) { | 11 | export default function init(stores) { |
@@ -19,7 +19,7 @@ export default function init(stores) { | |||
19 | 19 | ||
20 | const { isSpellcheckerPremiumFeature } = stores.features.features; | 20 | const { isSpellcheckerPremiumFeature } = stores.features.features; |
21 | 21 | ||
22 | config.isPremiumFeature = isSpellcheckerPremiumFeature !== undefined ? isSpellcheckerPremiumFeature : DEFAULT_IS_PREMIUM_FEATURE; | 22 | config.isPremiumFeature = isSpellcheckerPremiumFeature !== undefined ? isSpellcheckerPremiumFeature : DEFAULT_FEATURES_CONFIG.isSpellcheckerPremiumFeature; |
23 | 23 | ||
24 | autorun(() => { | 24 | autorun(() => { |
25 | if (!stores.user.data.isPremium && config.isPremiumFeature) { | 25 | if (!stores.user.data.isPremium && config.isPremiumFeature) { |
diff --git a/src/stores/FeaturesStore.js b/src/stores/FeaturesStore.js index 59abeb218..9480e27ab 100644 --- a/src/stores/FeaturesStore.js +++ b/src/stores/FeaturesStore.js | |||
@@ -7,6 +7,8 @@ import delayApp from '../features/delayApp'; | |||
7 | import spellchecker from '../features/spellchecker'; | 7 | import spellchecker from '../features/spellchecker'; |
8 | import serviceProxy from '../features/serviceProxy'; | 8 | import serviceProxy from '../features/serviceProxy'; |
9 | 9 | ||
10 | import { DEFAULT_FEATURES_CONFIG } from '../config'; | ||
11 | |||
10 | export default class FeaturesStore extends Store { | 12 | export default class FeaturesStore extends Store { |
11 | @observable defaultFeaturesRequest = new CachedRequest(this.api.features, 'default'); | 13 | @observable defaultFeaturesRequest = new CachedRequest(this.api.features, 'default'); |
12 | @observable featuresRequest = new CachedRequest(this.api.features, 'features'); | 14 | @observable featuresRequest = new CachedRequest(this.api.features, 'features'); |
@@ -22,10 +24,10 @@ export default class FeaturesStore extends Store { | |||
22 | 24 | ||
23 | @computed get features() { | 25 | @computed get features() { |
24 | if (this.stores.user.isLoggedIn) { | 26 | if (this.stores.user.isLoggedIn) { |
25 | return this.featuresRequest.execute().result || {}; | 27 | return this.featuresRequest.execute().result || DEFAULT_FEATURES_CONFIG; |
26 | } | 28 | } |
27 | 29 | ||
28 | return this.defaultFeaturesRequest.execute().result || {}; | 30 | return this.defaultFeaturesRequest.execute().result || DEFAULT_FEATURES_CONFIG; |
29 | } | 31 | } |
30 | 32 | ||
31 | _monitorLoginStatus() { | 33 | _monitorLoginStatus() { |
diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js index 9d8ac5657..d1e6d6570 100644 --- a/src/stores/UserStore.js +++ b/src/stores/UserStore.js | |||
@@ -122,13 +122,13 @@ export default class UserStore extends Store { | |||
122 | } | 122 | } |
123 | 123 | ||
124 | @computed get data() { | 124 | @computed get data() { |
125 | this.getUserInfoRequest.execute(); | 125 | if (!this.isLoggedIn) return {}; |
126 | return this.getUserInfoRequest.result || {}; | 126 | |
127 | return this.getUserInfoRequest.execute().result || {}; | ||
127 | } | 128 | } |
128 | 129 | ||
129 | @computed get legacyServices() { | 130 | @computed get legacyServices() { |
130 | this.getLegacyServicesRequest.execute(); | 131 | return this.getLegacyServicesRequest.execute() || {}; |
131 | return this.getLegacyServicesRequest.result || []; | ||
132 | } | 132 | } |
133 | 133 | ||
134 | // Actions | 134 | // Actions |