diff options
author | 2019-01-09 15:39:45 +0100 | |
---|---|---|
committer | 2019-01-09 15:39:45 +0100 | |
commit | 08c40f00de99f2e49f07106c241110f7afa71f6c (patch) | |
tree | 12e516faca9fb94cf5beee9cd4396f7d869c75de | |
parent | Merge branch 'feature/basicAuth' into develop (diff) | |
download | ferdium-app-08c40f00de99f2e49f07106c241110f7afa71f6c.tar.gz ferdium-app-08c40f00de99f2e49f07106c241110f7afa71f6c.tar.zst ferdium-app-08c40f00de99f2e49f07106c241110f7afa71f6c.zip |
fix(App): Fix app delay for Premium Supporters
-rw-r--r-- | src/containers/settings/AccountScreen.js | 8 | ||||
-rw-r--r-- | src/features/delayApp/index.js | 26 | ||||
-rw-r--r-- | src/stores/FeaturesStore.js | 9 |
3 files changed, 27 insertions, 16 deletions
diff --git a/src/containers/settings/AccountScreen.js b/src/containers/settings/AccountScreen.js index 019b3d7d6..d681d5226 100644 --- a/src/containers/settings/AccountScreen.js +++ b/src/containers/settings/AccountScreen.js | |||
@@ -14,6 +14,14 @@ import ErrorBoundary from '../../components/util/ErrorBoundary'; | |||
14 | const { BrowserWindow } = remote; | 14 | const { BrowserWindow } = remote; |
15 | 15 | ||
16 | export default @inject('stores', 'actions') @observer class AccountScreen extends Component { | 16 | export default @inject('stores', 'actions') @observer class AccountScreen extends Component { |
17 | componentWillMount() { | ||
18 | const { | ||
19 | user, | ||
20 | } = this.props.stores; | ||
21 | |||
22 | user.getUserInfoRequest.invalidate({ immediately: true }); | ||
23 | } | ||
24 | |||
17 | componentDidMount() { | 25 | componentDidMount() { |
18 | gaPage('Settings/Account Dashboard'); | 26 | gaPage('Settings/Account Dashboard'); |
19 | } | 27 | } |
diff --git a/src/features/delayApp/index.js b/src/features/delayApp/index.js index d7e8252f3..28aa50eb2 100644 --- a/src/features/delayApp/index.js +++ b/src/features/delayApp/index.js | |||
@@ -23,29 +23,23 @@ function setVisibility(value) { | |||
23 | } | 23 | } |
24 | 24 | ||
25 | export default function init(stores) { | 25 | export default function init(stores) { |
26 | reaction( | 26 | debug('Initializing `delayApp` feature'); |
27 | () => stores.features.features.needToWaitToProceed, | ||
28 | (enabled, r) => { | ||
29 | if (enabled) { | ||
30 | debug('Initializing `delayApp` feature'); | ||
31 | 27 | ||
32 | // Dispose the reaction to run this only once | 28 | let shownAfterLaunch = false; |
33 | r.dispose(); | 29 | let timeLastDelay = moment(); |
34 | 30 | ||
35 | const { needToWaitToProceedConfig: globalConfig } = stores.features.features; | 31 | reaction( |
32 | () => stores.features.features.needToWaitToProceed && !stores.user.data.isPremium, | ||
33 | (isEnabled) => { | ||
34 | if (isEnabled) { | ||
35 | debug('Enabling `delayApp` feature'); | ||
36 | 36 | ||
37 | let shownAfterLaunch = false; | 37 | const { needToWaitToProceedConfig: globalConfig } = stores.features.features; |
38 | let timeLastDelay = moment(); | ||
39 | 38 | ||
40 | config.delayOffset = globalConfig.delayOffset !== undefined ? globalConfig.delayOffset : DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.delayOffset; | 39 | config.delayOffset = globalConfig.delayOffset !== undefined ? globalConfig.delayOffset : DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.delayOffset; |
41 | config.delayDuration = globalConfig.wait !== undefined ? globalConfig.wait : DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.wait; | 40 | config.delayDuration = globalConfig.wait !== undefined ? globalConfig.wait : DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.wait; |
42 | 41 | ||
43 | autorun(() => { | 42 | autorun(() => { |
44 | if (stores.user.data.isPremium) { | ||
45 | debug('Skipping app delay as user is Premium Supporter'); | ||
46 | return; | ||
47 | } | ||
48 | |||
49 | if (stores.services.all.length === 0) { | 43 | if (stores.services.all.length === 0) { |
50 | shownAfterLaunch = true; | 44 | shownAfterLaunch = true; |
51 | return; | 45 | return; |
@@ -68,6 +62,8 @@ export default function init(stores) { | |||
68 | }, DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.wait + 1000); // timer needs to be able to hit 0 | 62 | }, DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.wait + 1000); // timer needs to be able to hit 0 |
69 | } | 63 | } |
70 | }); | 64 | }); |
65 | } else { | ||
66 | setVisibility(false); | ||
71 | } | 67 | } |
72 | }, | 68 | }, |
73 | ); | 69 | ); |
diff --git a/src/stores/FeaturesStore.js b/src/stores/FeaturesStore.js index 2eccf87ee..0adee6adf 100644 --- a/src/stores/FeaturesStore.js +++ b/src/stores/FeaturesStore.js | |||
@@ -1,4 +1,4 @@ | |||
1 | import { computed, observable } from 'mobx'; | 1 | import { computed, observable, reaction } from 'mobx'; |
2 | 2 | ||
3 | import Store from './lib/Store'; | 3 | import Store from './lib/Store'; |
4 | import CachedRequest from './lib/CachedRequest'; | 4 | import CachedRequest from './lib/CachedRequest'; |
@@ -22,6 +22,13 @@ export default class FeaturesStore extends Store { | |||
22 | 22 | ||
23 | await this.featuresRequest._promise; | 23 | await this.featuresRequest._promise; |
24 | setTimeout(this._enableFeatures.bind(this), 1); | 24 | setTimeout(this._enableFeatures.bind(this), 1); |
25 | |||
26 | // single key reaction | ||
27 | reaction(() => this.stores.user.data.isPremium, () => { | ||
28 | if (this.stores.user.isLoggedIn) { | ||
29 | this.featuresRequest.invalidate({ immediately: true }); | ||
30 | } | ||
31 | }); | ||
25 | } | 32 | } |
26 | 33 | ||
27 | @computed get anonymousFeatures() { | 34 | @computed get anonymousFeatures() { |