diff options
author | Dominik Guzei <dominik.guzei@gmail.com> | 2019-04-11 16:44:16 +0200 |
---|---|---|
committer | Dominik Guzei <dominik.guzei@gmail.com> | 2019-04-11 16:44:16 +0200 |
commit | eaf4aff646eed56e65c8dd8e70143ab5634ad4b4 (patch) | |
tree | ae400dca67edfd828a30da1e11d7e5e507785860 /src/features/workspaces/store.js | |
parent | refactor announcements to newest feature pattern (diff) | |
download | ferdium-app-eaf4aff646eed56e65c8dd8e70143ab5634ad4b4.tar.gz ferdium-app-eaf4aff646eed56e65c8dd8e70143ab5634ad4b4.tar.zst ferdium-app-eaf4aff646eed56e65c8dd8e70143ab5634ad4b4.zip |
WIP: announcement feature and workspace fixes
Diffstat (limited to 'src/features/workspaces/store.js')
-rw-r--r-- | src/features/workspaces/store.js | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/features/workspaces/store.js b/src/features/workspaces/store.js index ea601700e..4841a4e08 100644 --- a/src/features/workspaces/store.js +++ b/src/features/workspaces/store.js | |||
@@ -51,12 +51,16 @@ export default class WorkspacesStore extends FeatureStore { | |||
51 | return getUserWorkspacesRequest.wasExecuted && this.workspaces.length > 0; | 51 | return getUserWorkspacesRequest.wasExecuted && this.workspaces.length > 0; |
52 | } | 52 | } |
53 | 53 | ||
54 | @computed get isUserAllowedToUseFeature() { | ||
55 | return !this.isPremiumUpgradeRequired; | ||
56 | } | ||
57 | |||
54 | start(stores, actions) { | 58 | start(stores, actions) { |
55 | debug('WorkspacesStore::start'); | 59 | debug('WorkspacesStore::start'); |
56 | this.stores = stores; | 60 | this.stores = stores; |
57 | this.actions = actions; | 61 | this.actions = actions; |
58 | 62 | ||
59 | this._listenToActions([ | 63 | this._registerActions([ |
60 | [workspaceActions.edit, this._edit], | 64 | [workspaceActions.edit, this._edit], |
61 | [workspaceActions.create, this._create], | 65 | [workspaceActions.create, this._create], |
62 | [workspaceActions.delete, this._delete], | 66 | [workspaceActions.delete, this._delete], |
@@ -67,7 +71,7 @@ export default class WorkspacesStore extends FeatureStore { | |||
67 | [workspaceActions.openWorkspaceSettings, this._openWorkspaceSettings], | 71 | [workspaceActions.openWorkspaceSettings, this._openWorkspaceSettings], |
68 | ]); | 72 | ]); |
69 | 73 | ||
70 | this._startReactions([ | 74 | this._registerReactions([ |
71 | this._setWorkspaceBeingEditedReaction, | 75 | this._setWorkspaceBeingEditedReaction, |
72 | this._setActiveServiceOnWorkspaceSwitchReaction, | 76 | this._setActiveServiceOnWorkspaceSwitchReaction, |
73 | this._setFeatureEnabledReaction, | 77 | this._setFeatureEnabledReaction, |
@@ -75,6 +79,7 @@ export default class WorkspacesStore extends FeatureStore { | |||
75 | this._activateLastUsedWorkspaceReaction, | 79 | this._activateLastUsedWorkspaceReaction, |
76 | this._openDrawerWithSettingsReaction, | 80 | this._openDrawerWithSettingsReaction, |
77 | this._cleanupInvalidServiceReferences, | 81 | this._cleanupInvalidServiceReferences, |
82 | this._disableActionsForFreeUser, | ||
78 | ]); | 83 | ]); |
79 | 84 | ||
80 | getUserWorkspacesRequest.execute(); | 85 | getUserWorkspacesRequest.execute(); |
@@ -82,6 +87,7 @@ export default class WorkspacesStore extends FeatureStore { | |||
82 | } | 87 | } |
83 | 88 | ||
84 | stop() { | 89 | stop() { |
90 | super.stop(); | ||
85 | debug('WorkspacesStore::stop'); | 91 | debug('WorkspacesStore::stop'); |
86 | this.isFeatureActive = false; | 92 | this.isFeatureActive = false; |
87 | this.activeWorkspace = null; | 93 | this.activeWorkspace = null; |
@@ -273,4 +279,12 @@ export default class WorkspacesStore extends FeatureStore { | |||
273 | getUserWorkspacesRequest.execute(); | 279 | getUserWorkspacesRequest.execute(); |
274 | } | 280 | } |
275 | }; | 281 | }; |
282 | |||
283 | _disableActionsForFreeUser = () => { | ||
284 | if (!this.isUserAllowedToUseFeature) { | ||
285 | this._stopListeningToActions(); | ||
286 | } else { | ||
287 | this._startListeningToActions(); | ||
288 | } | ||
289 | } | ||
276 | } | 290 | } |