diff options
author | Stefan Malzner <stefan@adlk.io> | 2018-11-24 20:36:09 +0100 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2018-11-24 20:36:09 +0100 |
commit | 217cb8cdba811b93394811c6d616267cdf838eee (patch) | |
tree | 3683490e8288dbd179d4d60a09247287191e3b65 /src/stores | |
parent | Delay app based on featureAPI settings (diff) | |
download | ferdium-app-217cb8cdba811b93394811c6d616267cdf838eee.tar.gz ferdium-app-217cb8cdba811b93394811c6d616267cdf838eee.tar.zst ferdium-app-217cb8cdba811b93394811c6d616267cdf838eee.zip |
Add missing delayApp commit
Diffstat (limited to 'src/stores')
-rw-r--r-- | src/stores/AppStore.js | 14 | ||||
-rw-r--r-- | src/stores/FeaturesStore.js | 16 |
2 files changed, 24 insertions, 6 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 9ad4cd531..3e8b18801 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -12,6 +12,7 @@ import { CHECK_INTERVAL, DEFAULT_APP_SETTINGS } from '../config'; | |||
12 | import { isMac, isLinux, isWindows } from '../environment'; | 12 | import { isMac, isLinux, isWindows } from '../environment'; |
13 | import locales from '../i18n/translations'; | 13 | import locales from '../i18n/translations'; |
14 | import { gaEvent } from '../lib/analytics'; | 14 | import { gaEvent } from '../lib/analytics'; |
15 | import { onVisibilityChange } from '../helpers/visibility-helper'; | ||
15 | 16 | ||
16 | import { getServiceIdsFromPartitions, removeServicePartitionDirectory } from '../helpers/service-helpers.js'; | 17 | import { getServiceIdsFromPartitions, removeServicePartitionDirectory } from '../helpers/service-helpers.js'; |
17 | 18 | ||
@@ -56,6 +57,8 @@ export default class AppStore extends Store { | |||
56 | 57 | ||
57 | @observable isFullScreen = mainWindow.isFullScreen(); | 58 | @observable isFullScreen = mainWindow.isFullScreen(); |
58 | 59 | ||
60 | @observable isFocused = true; | ||
61 | |||
59 | constructor(...args) { | 62 | constructor(...args) { |
60 | super(...args); | 63 | super(...args); |
61 | 64 | ||
@@ -163,6 +166,17 @@ export default class AppStore extends Store { | |||
163 | this._healthCheck(); | 166 | this._healthCheck(); |
164 | 167 | ||
165 | this.isSystemDarkModeEnabled = systemPreferences.isDarkMode(); | 168 | this.isSystemDarkModeEnabled = systemPreferences.isDarkMode(); |
169 | |||
170 | onVisibilityChange((isVisible) => { | ||
171 | this.isFocused = isVisible; | ||
172 | // debug('Last focus', moment().diff(this.timeLastFocusStart)); | ||
173 | |||
174 | // if (isVisible) { | ||
175 | // this.timeLastFocusStart = moment(); | ||
176 | // } | ||
177 | |||
178 | debug('Window is visible/focused', isVisible); | ||
179 | }); | ||
166 | } | 180 | } |
167 | 181 | ||
168 | @computed get cacheSize() { | 182 | @computed get cacheSize() { |
diff --git a/src/stores/FeaturesStore.js b/src/stores/FeaturesStore.js index f788c347d..9740d078f 100644 --- a/src/stores/FeaturesStore.js +++ b/src/stores/FeaturesStore.js | |||
@@ -3,15 +3,19 @@ import { computed, observable } from 'mobx'; | |||
3 | import Store from './lib/Store'; | 3 | import Store from './lib/Store'; |
4 | import CachedRequest from './lib/CachedRequest'; | 4 | import CachedRequest from './lib/CachedRequest'; |
5 | 5 | ||
6 | import delayApp from '../features/delayApp'; | ||
7 | |||
6 | export default class FeaturesStore extends Store { | 8 | export default class FeaturesStore extends Store { |
7 | @observable defaultFeaturesRequest = new CachedRequest(this.api.features, 'default'); | 9 | @observable defaultFeaturesRequest = new CachedRequest(this.api.features, 'default'); |
8 | @observable featuresRequest = new CachedRequest(this.api.features, 'features'); | 10 | @observable featuresRequest = new CachedRequest(this.api.features, 'features'); |
9 | 11 | ||
10 | setup() { | 12 | async setup() { |
11 | this.registerReactions([ | 13 | this.registerReactions([ |
12 | this._monitorLoginStatus.bind(this), | 14 | this._monitorLoginStatus.bind(this), |
13 | this._debugFeatures.bind(this), | ||
14 | ]); | 15 | ]); |
16 | |||
17 | await this.featuresRequest._promise; | ||
18 | setTimeout(this._enableFeatures.bind(this), 1); | ||
15 | } | 19 | } |
16 | 20 | ||
17 | @computed get features() { | 21 | @computed get features() { |
@@ -22,10 +26,6 @@ export default class FeaturesStore extends Store { | |||
22 | return this.defaultFeaturesRequest.execute().result || {}; | 26 | return this.defaultFeaturesRequest.execute().result || {}; |
23 | } | 27 | } |
24 | 28 | ||
25 | _debugFeatures() { | ||
26 | console.log(this.features); | ||
27 | } | ||
28 | |||
29 | _monitorLoginStatus() { | 29 | _monitorLoginStatus() { |
30 | if (this.stores.user.isLoggedIn) { | 30 | if (this.stores.user.isLoggedIn) { |
31 | this.featuresRequest.invalidate({ immediately: true }); | 31 | this.featuresRequest.invalidate({ immediately: true }); |
@@ -33,4 +33,8 @@ export default class FeaturesStore extends Store { | |||
33 | this.defaultFeaturesRequest.invalidate({ immediately: true }); | 33 | this.defaultFeaturesRequest.invalidate({ immediately: true }); |
34 | } | 34 | } |
35 | } | 35 | } |
36 | |||
37 | _enableFeatures() { | ||
38 | delayApp(this.stores, this.actions); | ||
39 | } | ||
36 | } | 40 | } |