aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/workspaces/store.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/features/workspaces/store.js')
-rw-r--r--src/features/workspaces/store.js38
1 files changed, 13 insertions, 25 deletions
diff --git a/src/features/workspaces/store.js b/src/features/workspaces/store.js
index 8c73516bc..ec9d7ee7f 100644
--- a/src/features/workspaces/store.js
+++ b/src/features/workspaces/store.js
@@ -155,38 +155,26 @@ export default class WorkspacesStore extends FeatureStore {
155 }; 155 };
156 156
157 @action _create = async ({ name }) => { 157 @action _create = async ({ name }) => {
158 // eslint-disable-next-line no-useless-catch 158 const workspace = await createWorkspaceRequest.execute(name);
159 try { 159 await getUserWorkspacesRequest.result.push(workspace);
160 const workspace = await createWorkspaceRequest.execute(name); 160 this._edit({ workspace });
161 await getUserWorkspacesRequest.result.push(workspace);
162 this._edit({ workspace });
163 } catch (error) {
164 throw error;
165 }
166 }; 161 };
167 162
168 @action _delete = async ({ workspace }) => { 163 @action _delete = async ({ workspace }) => {
169 // eslint-disable-next-line no-useless-catch 164 await deleteWorkspaceRequest.execute(workspace);
170 try { 165 await getUserWorkspacesRequest.result.remove(workspace);
171 await deleteWorkspaceRequest.execute(workspace); 166 this.stores.router.push('/settings/workspaces');
172 await getUserWorkspacesRequest.result.remove(workspace); 167 if (this.activeWorkspace === workspace) {
173 this.stores.router.push('/settings/workspaces'); 168 this._deactivateActiveWorkspace();
174 } catch (error) {
175 throw error;
176 } 169 }
177 }; 170 };
178 171
179 @action _update = async ({ workspace }) => { 172 @action _update = async ({ workspace }) => {
180 // eslint-disable-next-line no-useless-catch 173 await updateWorkspaceRequest.execute(workspace);
181 try { 174 // Path local result optimistically
182 await updateWorkspaceRequest.execute(workspace); 175 const localWorkspace = this._getWorkspaceById(workspace.id);
183 // Path local result optimistically 176 Object.assign(localWorkspace, workspace);
184 const localWorkspace = this._getWorkspaceById(workspace.id); 177 this.stores.router.push('/settings/workspaces');
185 Object.assign(localWorkspace, workspace);
186 this.stores.router.push('/settings/workspaces');
187 } catch (error) {
188 throw error;
189 }
190 }; 178 };
191 179
192 @action _setActiveWorkspace = ({ workspace }) => { 180 @action _setActiveWorkspace = ({ workspace }) => {