aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/workspaces/store.js
diff options
context:
space:
mode:
authorLibravatar Dominik Guzei <dominik.guzei@gmail.com>2019-04-04 14:02:34 +0200
committerLibravatar Dominik Guzei <dominik.guzei@gmail.com>2019-04-04 14:02:34 +0200
commit913b9e8614be3ae1e904423311d3adf55a210e5d (patch)
tree22417a435b840485180c66f99596b38d45a49899 /src/features/workspaces/store.js
parentadd open last used workspace logic (diff)
downloadferdium-app-913b9e8614be3ae1e904423311d3adf55a210e5d.tar.gz
ferdium-app-913b9e8614be3ae1e904423311d3adf55a210e5d.tar.zst
ferdium-app-913b9e8614be3ae1e904423311d3adf55a210e5d.zip
use mobx-localstorage directly in the store
Diffstat (limited to 'src/features/workspaces/store.js')
-rw-r--r--src/features/workspaces/store.js9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/features/workspaces/store.js b/src/features/workspaces/store.js
index 2abb91c22..4d65712a7 100644
--- a/src/features/workspaces/store.js
+++ b/src/features/workspaces/store.js
@@ -3,13 +3,14 @@ import {
3 observable, 3 observable,
4 action, 4 action,
5} from 'mobx'; 5} from 'mobx';
6import localStorage from 'mobx-localstorage';
6import { matchRoute } from '../../helpers/routing-helpers'; 7import { matchRoute } from '../../helpers/routing-helpers';
7import { workspaceActions } from './actions'; 8import { workspaceActions } from './actions';
8import { FeatureStore } from '../utils/FeatureStore'; 9import { FeatureStore } from '../utils/FeatureStore';
9import { 10import {
10 createWorkspaceRequest, 11 createWorkspaceRequest,
11 deleteWorkspaceRequest, 12 deleteWorkspaceRequest,
12 getUserWorkspacesRequest, getWorkspaceSettingsRequest, setWorkspaceSettingsRequest, 13 getUserWorkspacesRequest,
13 updateWorkspaceRequest, 14 updateWorkspaceRequest,
14} from './api'; 15} from './api';
15 16
@@ -38,7 +39,7 @@ export default class WorkspacesStore extends FeatureStore {
38 } 39 }
39 40
40 @computed get settings() { 41 @computed get settings() {
41 return getWorkspaceSettingsRequest.result; 42 return localStorage.getItem('workspaces') || {};
42 } 43 }
43 44
44 @computed get userHasWorkspaces() { 45 @computed get userHasWorkspaces() {
@@ -74,7 +75,6 @@ export default class WorkspacesStore extends FeatureStore {
74 ]); 75 ]);
75 76
76 getUserWorkspacesRequest.execute(); 77 getUserWorkspacesRequest.execute();
77 getWorkspaceSettingsRequest.execute();
78 this.isFeatureActive = true; 78 this.isFeatureActive = true;
79 } 79 }
80 80
@@ -105,7 +105,7 @@ export default class WorkspacesStore extends FeatureStore {
105 _getWorkspaceById = id => this.workspaces.find(w => w.id === id); 105 _getWorkspaceById = id => this.workspaces.find(w => w.id === id);
106 106
107 _updateSettings = (changes) => { 107 _updateSettings = (changes) => {
108 setWorkspaceSettingsRequest.execute({ 108 localStorage.setItem('workspaces', {
109 ...this.settings, 109 ...this.settings,
110 ...changes, 110 ...changes,
111 }); 111 });
@@ -170,7 +170,6 @@ export default class WorkspacesStore extends FeatureStore {
170 this.isSwitchingWorkspace = true; 170 this.isSwitchingWorkspace = true;
171 this.nextWorkspace = null; 171 this.nextWorkspace = null;
172 this._updateSettings({ lastActiveWorkspace: null }); 172 this._updateSettings({ lastActiveWorkspace: null });
173 getWorkspaceSettingsRequest.execute();
174 // Delay switching to next workspace so that the services loading does not drag down UI 173 // Delay switching to next workspace so that the services loading does not drag down UI
175 setTimeout(() => { 174 setTimeout(() => {
176 this.activeWorkspace = null; 175 this.activeWorkspace = null;