aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/FeaturesStore.js
diff options
context:
space:
mode:
authorLibravatar Dominik Guzei <dominik.guzei@gmail.com>2019-03-28 16:23:17 +0100
committerLibravatar Dominik Guzei <dominik.guzei@gmail.com>2019-03-28 16:23:17 +0100
commit7941831bf773b49944001c095a1949a1bdec2cf2 (patch)
tree5dbcbf097e340c381617410e032c2db6b811096e /src/stores/FeaturesStore.js
parentimprove styling of workspace switch indicator (diff)
downloadferdium-app-7941831bf773b49944001c095a1949a1bdec2cf2.tar.gz
ferdium-app-7941831bf773b49944001c095a1949a1bdec2cf2.tar.zst
ferdium-app-7941831bf773b49944001c095a1949a1bdec2cf2.zip
add workspace premium notice to dashboard
Diffstat (limited to 'src/stores/FeaturesStore.js')
-rw-r--r--src/stores/FeaturesStore.js18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/stores/FeaturesStore.js b/src/stores/FeaturesStore.js
index 2bda82e17..52e38ad96 100644
--- a/src/stores/FeaturesStore.js
+++ b/src/stores/FeaturesStore.js
@@ -1,4 +1,4 @@
1import { computed, observable, reaction } from 'mobx'; 1import { computed, observable, reaction, runInAction } from 'mobx';
2 2
3import Store from './lib/Store'; 3import Store from './lib/Store';
4import CachedRequest from './lib/CachedRequest'; 4import CachedRequest from './lib/CachedRequest';
@@ -17,8 +17,11 @@ export default class FeaturesStore extends Store {
17 17
18 @observable featuresRequest = new CachedRequest(this.api.features, 'features'); 18 @observable featuresRequest = new CachedRequest(this.api.features, 'features');
19 19
20 @observable features = Object.assign({}, DEFAULT_FEATURES_CONFIG);
21
20 async setup() { 22 async setup() {
21 this.registerReactions([ 23 this.registerReactions([
24 this._updateFeatures,
22 this._monitorLoginStatus.bind(this), 25 this._monitorLoginStatus.bind(this),
23 ]); 26 ]);
24 27
@@ -37,13 +40,16 @@ export default class FeaturesStore extends Store {
37 return this.defaultFeaturesRequest.execute().result || DEFAULT_FEATURES_CONFIG; 40 return this.defaultFeaturesRequest.execute().result || DEFAULT_FEATURES_CONFIG;
38 } 41 }
39 42
40 @computed get features() { 43 _updateFeatures = () => {
44 const features = Object.assign({}, DEFAULT_FEATURES_CONFIG);
41 if (this.stores.user.isLoggedIn) { 45 if (this.stores.user.isLoggedIn) {
42 return Object.assign({}, DEFAULT_FEATURES_CONFIG, this.featuresRequest.execute().result); 46 const requestResult = this.featuresRequest.execute().result;
47 Object.assign(features, requestResult);
43 } 48 }
44 49 runInAction('FeaturesStore::_updateFeatures', () => {
45 return DEFAULT_FEATURES_CONFIG; 50 this.features = features;
46 } 51 });
52 };
47 53
48 _monitorLoginStatus() { 54 _monitorLoginStatus() {
49 if (this.stores.user.isLoggedIn) { 55 if (this.stores.user.isLoggedIn) {