diff options
author | Dominik Guzei <dominik.guzei@gmail.com> | 2019-07-10 14:34:30 +0200 |
---|---|---|
committer | Dominik Guzei <dominik.guzei@gmail.com> | 2019-07-10 14:34:30 +0200 |
commit | 052947735bae0f2c5c6876ba60941aa84888576e (patch) | |
tree | 97585c973ad1bbebf11f2bf89204d348eb2bd61f /src | |
parent | Merge branch 'release/5.2.0-beta.2' (diff) | |
download | ferdium-app-052947735bae0f2c5c6876ba60941aa84888576e.tar.gz ferdium-app-052947735bae0f2c5c6876ba60941aa84888576e.tar.zst ferdium-app-052947735bae0f2c5c6876ba60941aa84888576e.zip |
fix reactions and workspace cleanup logic
Diffstat (limited to 'src')
-rw-r--r-- | src/features/workspaces/store.js | 21 | ||||
-rw-r--r-- | src/stores/lib/Reaction.js | 6 |
2 files changed, 17 insertions, 10 deletions
diff --git a/src/features/workspaces/store.js b/src/features/workspaces/store.js index 07b16ff23..a82f6895c 100644 --- a/src/features/workspaces/store.js +++ b/src/features/workspaces/store.js | |||
@@ -79,7 +79,7 @@ export default class WorkspacesStore extends FeatureStore { | |||
79 | 79 | ||
80 | // ========== PUBLIC API ========= // | 80 | // ========== PUBLIC API ========= // |
81 | 81 | ||
82 | start(stores, actions) { | 82 | @action start(stores, actions) { |
83 | debug('WorkspacesStore::start'); | 83 | debug('WorkspacesStore::start'); |
84 | this.stores = stores; | 84 | this.stores = stores; |
85 | this.actions = actions; | 85 | this.actions = actions; |
@@ -104,7 +104,7 @@ export default class WorkspacesStore extends FeatureStore { | |||
104 | // REACTIONS | 104 | // REACTIONS |
105 | 105 | ||
106 | this._freeUserReactions = createReactions([ | 106 | this._freeUserReactions = createReactions([ |
107 | this._stopPremiumActionsAndReactions, | 107 | this._disablePremiumFeatures, |
108 | this._openDrawerWithSettingsReaction, | 108 | this._openDrawerWithSettingsReaction, |
109 | this._setFeatureEnabledReaction, | 109 | this._setFeatureEnabledReaction, |
110 | this._setIsPremiumFeatureReaction, | 110 | this._setIsPremiumFeatureReaction, |
@@ -123,10 +123,7 @@ export default class WorkspacesStore extends FeatureStore { | |||
123 | this.isFeatureActive = true; | 123 | this.isFeatureActive = true; |
124 | } | 124 | } |
125 | 125 | ||
126 | stop() { | 126 | @action reset() { |
127 | super.stop(); | ||
128 | debug('WorkspacesStore::stop'); | ||
129 | this.isFeatureActive = false; | ||
130 | this.activeWorkspace = null; | 127 | this.activeWorkspace = null; |
131 | this.nextWorkspace = null; | 128 | this.nextWorkspace = null; |
132 | this.workspaceBeingEdited = null; | 129 | this.workspaceBeingEdited = null; |
@@ -134,6 +131,13 @@ export default class WorkspacesStore extends FeatureStore { | |||
134 | this.isWorkspaceDrawerOpen = false; | 131 | this.isWorkspaceDrawerOpen = false; |
135 | } | 132 | } |
136 | 133 | ||
134 | @action stop() { | ||
135 | super.stop(); | ||
136 | debug('WorkspacesStore::stop'); | ||
137 | this.reset(); | ||
138 | this.isFeatureActive = false; | ||
139 | } | ||
140 | |||
137 | filterServicesByActiveWorkspace = (services) => { | 141 | filterServicesByActiveWorkspace = (services) => { |
138 | const { activeWorkspace, isFeatureActive } = this; | 142 | const { activeWorkspace, isFeatureActive } = this; |
139 | if (isFeatureActive && activeWorkspace) { | 143 | if (isFeatureActive && activeWorkspace) { |
@@ -281,6 +285,7 @@ export default class WorkspacesStore extends FeatureStore { | |||
281 | }; | 285 | }; |
282 | 286 | ||
283 | _activateLastUsedWorkspaceReaction = () => { | 287 | _activateLastUsedWorkspaceReaction = () => { |
288 | debug('_activateLastUsedWorkspaceReaction'); | ||
284 | if (!this.activeWorkspace && this.userHasWorkspaces) { | 289 | if (!this.activeWorkspace && this.userHasWorkspaces) { |
285 | const { lastActiveWorkspace } = this.settings; | 290 | const { lastActiveWorkspace } = this.settings; |
286 | if (lastActiveWorkspace) { | 291 | if (lastActiveWorkspace) { |
@@ -324,10 +329,12 @@ export default class WorkspacesStore extends FeatureStore { | |||
324 | }); | 329 | }); |
325 | }; | 330 | }; |
326 | 331 | ||
327 | _stopPremiumActionsAndReactions = () => { | 332 | _disablePremiumFeatures = () => { |
328 | if (!this.isUserAllowedToUseFeature) { | 333 | if (!this.isUserAllowedToUseFeature) { |
334 | debug('_disablePremiumFeatures'); | ||
329 | this._stopActions(this._premiumUserActions); | 335 | this._stopActions(this._premiumUserActions); |
330 | this._stopReactions(this._premiumUserReactions); | 336 | this._stopReactions(this._premiumUserReactions); |
337 | this.reset(); | ||
331 | } else { | 338 | } else { |
332 | this._startActions(this._premiumUserActions); | 339 | this._startActions(this._premiumUserActions); |
333 | this._startReactions(this._premiumUserReactions); | 340 | this._startReactions(this._premiumUserReactions); |
diff --git a/src/stores/lib/Reaction.js b/src/stores/lib/Reaction.js index f2642908f..f8009b7f6 100644 --- a/src/stores/lib/Reaction.js +++ b/src/stores/lib/Reaction.js | |||
@@ -13,15 +13,15 @@ export default class Reaction { | |||
13 | 13 | ||
14 | start() { | 14 | start() { |
15 | if (!this.isRunning) { | 15 | if (!this.isRunning) { |
16 | this.dispose = autorun(() => this.reaction()); | 16 | this.dispose = autorun(this.reaction); |
17 | this.isActive = true; | 17 | this.isRunning = true; |
18 | } | 18 | } |
19 | } | 19 | } |
20 | 20 | ||
21 | stop() { | 21 | stop() { |
22 | if (this.isRunning) { | 22 | if (this.isRunning) { |
23 | this.dispose(); | 23 | this.dispose(); |
24 | this.isActive = false; | 24 | this.isRunning = false; |
25 | } | 25 | } |
26 | } | 26 | } |
27 | } | 27 | } |