aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/workspaces/store.js
diff options
context:
space:
mode:
authorLibravatar Dominik Guzei <dominik.guzei@gmail.com>2019-04-05 20:46:10 +0200
committerLibravatar Dominik Guzei <dominik.guzei@gmail.com>2019-04-05 20:46:10 +0200
commit05d13dea31861df7366dfe40395c1b04462d02ce (patch)
treeded1f34728adeafa1e10cb57a521d64c656e10ac /src/features/workspaces/store.js
parentadd hover effect for drawer workspace items (diff)
downloadferdium-app-05d13dea31861df7366dfe40395c1b04462d02ce.tar.gz
ferdium-app-05d13dea31861df7366dfe40395c1b04462d02ce.tar.zst
ferdium-app-05d13dea31861df7366dfe40395c1b04462d02ce.zip
ensure drawer is open on workspace settings routes
Diffstat (limited to 'src/features/workspaces/store.js')
-rw-r--r--src/features/workspaces/store.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/features/workspaces/store.js b/src/features/workspaces/store.js
index 7bd969be0..2e1764f99 100644
--- a/src/features/workspaces/store.js
+++ b/src/features/workspaces/store.js
@@ -13,6 +13,7 @@ import {
13 getUserWorkspacesRequest, 13 getUserWorkspacesRequest,
14 updateWorkspaceRequest, 14 updateWorkspaceRequest,
15} from './api'; 15} from './api';
16import { WORKSPACES_ROUTES } from './index';
16 17
17const debug = require('debug')('Franz:feature:workspaces:store'); 18const debug = require('debug')('Franz:feature:workspaces:store');
18 19
@@ -70,6 +71,7 @@ export default class WorkspacesStore extends FeatureStore {
70 this._setFeatureEnabledReaction, 71 this._setFeatureEnabledReaction,
71 this._setIsPremiumFeatureReaction, 72 this._setIsPremiumFeatureReaction,
72 this._activateLastUsedWorkspaceReaction, 73 this._activateLastUsedWorkspaceReaction,
74 this._openDrawerWithSettingsReaction,
73 ]); 75 ]);
74 76
75 getUserWorkspacesRequest.execute(); 77 getUserWorkspacesRequest.execute();
@@ -100,6 +102,10 @@ export default class WorkspacesStore extends FeatureStore {
100 102
101 // ========== PRIVATE ========= // 103 // ========== PRIVATE ========= //
102 104
105 _wasDrawerOpenBeforeSettingsRoute = null;
106
107 _isSettingsRouteActive = null;
108
103 _getWorkspaceById = id => this.workspaces.find(w => w.id === id); 109 _getWorkspaceById = id => this.workspaces.find(w => w.id === id);
104 110
105 _updateSettings = (changes) => { 111 _updateSettings = (changes) => {
@@ -229,4 +235,24 @@ export default class WorkspacesStore extends FeatureStore {
229 } 235 }
230 } 236 }
231 }; 237 };
238
239 _openDrawerWithSettingsReaction = () => {
240 const { router } = this.stores;
241 const isWorkspaceSettingsRoute = router.location.pathname.includes(WORKSPACES_ROUTES.ROOT);
242 const isSwitchingToSettingsRoute = !this._isSettingsRouteActive && isWorkspaceSettingsRoute;
243 const isLeavingSettingsRoute = !isWorkspaceSettingsRoute && this._isSettingsRouteActive;
244
245 if (isSwitchingToSettingsRoute) {
246 this._isSettingsRouteActive = true;
247 this._wasDrawerOpenBeforeSettingsRoute = this.isWorkspaceDrawerOpen;
248 if (!this._wasDrawerOpenBeforeSettingsRoute) {
249 workspaceActions.toggleWorkspaceDrawer();
250 }
251 } else if (isLeavingSettingsRoute) {
252 this._isSettingsRouteActive = false;
253 if (!this._wasDrawerOpenBeforeSettingsRoute && this.isWorkspaceDrawerOpen) {
254 workspaceActions.toggleWorkspaceDrawer();
255 }
256 }
257 };
232} 258}