aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/FeaturesStore.js
diff options
context:
space:
mode:
authorLibravatar Ricardo Cino <ricardo@cino.io>2022-06-22 16:21:23 +0200
committerLibravatar Vijay Aravamudhan <vraravam@users.noreply.github.com>2022-06-23 17:50:07 +0530
commitcaf43fc8d64c27a1aad4a5d6507313c513c1a447 (patch)
treec0a7bcb950cdf555b3e8a33a57e2241e7051861d /src/stores/FeaturesStore.js
parentWorkaroud for in-app Password Recovery (#342) (diff)
downloadferdium-app-caf43fc8d64c27a1aad4a5d6507313c513c1a447.tar.gz
ferdium-app-caf43fc8d64c27a1aad4a5d6507313c513c1a447.tar.zst
ferdium-app-caf43fc8d64c27a1aad4a5d6507313c513c1a447.zip
chore: featureStore and GlobalErrorStore JS => TS
Diffstat (limited to 'src/stores/FeaturesStore.js')
-rw-r--r--src/stores/FeaturesStore.js77
1 files changed, 0 insertions, 77 deletions
diff --git a/src/stores/FeaturesStore.js b/src/stores/FeaturesStore.js
deleted file mode 100644
index e2c0c08ef..000000000
--- a/src/stores/FeaturesStore.js
+++ /dev/null
@@ -1,77 +0,0 @@
1import { computed, observable, runInAction } from 'mobx';
2
3import Store from './lib/Store';
4import CachedRequest from './lib/CachedRequest';
5
6import serviceProxy from '../features/serviceProxy';
7import basicAuth from '../features/basicAuth';
8import workspaces from '../features/workspaces';
9import quickSwitch from '../features/quickSwitch';
10import publishDebugInfo from '../features/publishDebugInfo';
11import communityRecipes from '../features/communityRecipes';
12import todos from '../features/todos';
13import appearance from '../features/appearance';
14
15export default class FeaturesStore extends Store {
16 @observable defaultFeaturesRequest = new CachedRequest(
17 this.api.features,
18 'default',
19 );
20
21 @observable featuresRequest = new CachedRequest(
22 this.api.features,
23 'features',
24 );
25
26 @observable features = {};
27
28 async setup() {
29 this.registerReactions([
30 this._updateFeatures,
31 this._monitorLoginStatus.bind(this),
32 ]);
33
34 await this.featuresRequest._promise;
35 setTimeout(this._setupFeatures.bind(this), 1);
36 }
37
38 @computed get anonymousFeatures() {
39 return this.defaultFeaturesRequest.execute().result || {};
40 }
41
42 _updateFeatures = () => {
43 const features = {};
44 if (this.stores.user.isLoggedIn) {
45 let requestResult = {};
46 try {
47 requestResult = this.featuresRequest.execute().result;
48 } catch (error) {
49 console.error(error);
50 }
51 Object.assign(features, requestResult);
52 }
53 runInAction('FeaturesStore::_updateFeatures', () => {
54 this.features = features;
55 });
56 };
57
58 _monitorLoginStatus() {
59 if (this.stores.user.isLoggedIn) {
60 this.featuresRequest.invalidate({ immediately: true });
61 } else {
62 this.defaultFeaturesRequest.execute();
63 this.defaultFeaturesRequest.invalidate({ immediately: true });
64 }
65 }
66
67 _setupFeatures() {
68 serviceProxy(this.stores);
69 basicAuth();
70 workspaces(this.stores, this.actions);
71 quickSwitch();
72 publishDebugInfo();
73 communityRecipes(this.stores, this.actions);
74 todos(this.stores, this.actions);
75 appearance(this.stores);
76 }
77}