aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/workspaces/store.js
diff options
context:
space:
mode:
authorLibravatar Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com>2021-09-01 09:29:49 +0530
committerLibravatar GitHub <noreply@github.com>2021-09-01 09:29:49 +0530
commitd0bad11661cb93756891e7fafe729b7f4e415fb1 (patch)
tree80faf451477cd9ae216ff5a8f92958c4ab23065a /src/features/workspaces/store.js
parentbuild(deps): bump tar from 4.4.15 to 4.4.18 (#1852) (diff)
downloadferdium-app-d0bad11661cb93756891e7fafe729b7f4e415fb1.tar.gz
ferdium-app-d0bad11661cb93756891e7fafe729b7f4e415fb1.tar.zst
ferdium-app-d0bad11661cb93756891e7fafe729b7f4e415fb1.zip
Fix issue with workspace feature - fixes #1682 (#1854)
* fix issue with workspace feature not being turned on, and then randomly turning on somehow. * when deleting the active workspace, auto-select the default workspace. * consolidated the toggling of features into a single place in the config file. Co-authored-by: Sadetdin EYILI <sadetdin.eyili@ekino.com> Signed-off-by: Vijay A <avijayr@protonmail.com>
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 }) => {