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.js46
1 files changed, 29 insertions, 17 deletions
diff --git a/src/features/workspaces/store.js b/src/features/workspaces/store.js
index db2b69f99..0fa43b723 100644
--- a/src/features/workspaces/store.js
+++ b/src/features/workspaces/store.js
@@ -124,7 +124,7 @@ export default class WorkspacesStore extends FeatureStore {
124 this.isFeatureActive = false; 124 this.isFeatureActive = false;
125 } 125 }
126 126
127 filterServicesByActiveWorkspace = (services) => { 127 filterServicesByActiveWorkspace = services => {
128 const { activeWorkspace, isFeatureActive } = this; 128 const { activeWorkspace, isFeatureActive } = this;
129 if (isFeatureActive && activeWorkspace) { 129 if (isFeatureActive && activeWorkspace) {
130 return this.getWorkspaceServices(activeWorkspace); 130 return this.getWorkspaceServices(activeWorkspace);
@@ -134,14 +134,14 @@ export default class WorkspacesStore extends FeatureStore {
134 134
135 getWorkspaceServices(workspace) { 135 getWorkspaceServices(workspace) {
136 const { services } = this.stores; 136 const { services } = this.stores;
137 return workspace.services.map((id) => services.one(id)).filter((s) => !!s); 137 return workspace.services.map(id => services.one(id)).filter(s => !!s);
138 } 138 }
139 139
140 // ========== PRIVATE METHODS ========= // 140 // ========== PRIVATE METHODS ========= //
141 141
142 _getWorkspaceById = (id) => this.workspaces.find((w) => w.id === id); 142 _getWorkspaceById = id => this.workspaces.find(w => w.id === id);
143 143
144 _updateSettings = (changes) => { 144 _updateSettings = changes => {
145 localStorage.setItem('workspaces', { 145 localStorage.setItem('workspaces', {
146 ...this.settings, 146 ...this.settings,
147 ...changes, 147 ...changes,
@@ -191,9 +191,15 @@ export default class WorkspacesStore extends FeatureStore {
191 this.isSwitchingWorkspace = false; 191 this.isSwitchingWorkspace = false;
192 this.nextWorkspace = null; 192 this.nextWorkspace = null;
193 if (this.stores.settings.app.splitMode) { 193 if (this.stores.settings.app.splitMode) {
194 const serviceNames = new Set(this.getWorkspaceServices(workspace).map(service => service.name)); 194 const serviceNames = new Set(
195 for (const wrapper of document.querySelectorAll('.services__webview-wrapper')) { 195 this.getWorkspaceServices(workspace).map(service => service.name),
196 wrapper.style.display = serviceNames.has(wrapper.dataset.name) ? '' : 'none'; 196 );
197 for (const wrapper of document.querySelectorAll(
198 '.services__webview-wrapper',
199 )) {
200 wrapper.style.display = serviceNames.has(wrapper.dataset.name)
201 ? ''
202 : 'none';
197 } 203 }
198 } 204 }
199 }, 1000); 205 }, 1000);
@@ -212,7 +218,9 @@ export default class WorkspacesStore extends FeatureStore {
212 setTimeout(() => { 218 setTimeout(() => {
213 this.isSwitchingWorkspace = false; 219 this.isSwitchingWorkspace = false;
214 if (this.stores.settings.app.splitMode) { 220 if (this.stores.settings.app.splitMode) {
215 for (const wrapper of document.querySelectorAll('.services__webview-wrapper')) { 221 for (const wrapper of document.querySelectorAll(
222 '.services__webview-wrapper',
223 )) {
216 wrapper.style.display = ''; 224 wrapper.style.display = '';
217 } 225 }
218 } 226 }
@@ -262,7 +270,8 @@ export default class WorkspacesStore extends FeatureStore {
262 const activeService = this.stores.services.active; 270 const activeService = this.stores.services.active;
263 const workspaceServices = this.getWorkspaceServices(this.activeWorkspace); 271 const workspaceServices = this.getWorkspaceServices(this.activeWorkspace);
264 if (workspaceServices.length <= 0) return; 272 if (workspaceServices.length <= 0) return;
265 const isActiveServiceInWorkspace = workspaceServices.includes(activeService); 273 const isActiveServiceInWorkspace =
274 workspaceServices.includes(activeService);
266 if (!isActiveServiceInWorkspace) { 275 if (!isActiveServiceInWorkspace) {
267 this.actions.service.setActive({ 276 this.actions.service.setActive({
268 serviceId: workspaceServices[0].id, 277 serviceId: workspaceServices[0].id,
@@ -288,8 +297,10 @@ export default class WorkspacesStore extends FeatureStore {
288 const isWorkspaceSettingsRoute = router.location.pathname.includes( 297 const isWorkspaceSettingsRoute = router.location.pathname.includes(
289 WORKSPACES_ROUTES.ROOT, 298 WORKSPACES_ROUTES.ROOT,
290 ); 299 );
291 const isSwitchingToSettingsRoute = !this.isSettingsRouteActive && isWorkspaceSettingsRoute; 300 const isSwitchingToSettingsRoute =
292 const isLeavingSettingsRoute = !isWorkspaceSettingsRoute && this.isSettingsRouteActive; 301 !this.isSettingsRouteActive && isWorkspaceSettingsRoute;
302 const isLeavingSettingsRoute =
303 !isWorkspaceSettingsRoute && this.isSettingsRouteActive;
293 304
294 if (isSwitchingToSettingsRoute) { 305 if (isSwitchingToSettingsRoute) {
295 this.isSettingsRouteActive = true; 306 this.isSettingsRouteActive = true;
@@ -300,8 +311,8 @@ export default class WorkspacesStore extends FeatureStore {
300 } else if (isLeavingSettingsRoute) { 311 } else if (isLeavingSettingsRoute) {
301 this.isSettingsRouteActive = false; 312 this.isSettingsRouteActive = false;
302 if ( 313 if (
303 !this._wasDrawerOpenBeforeSettingsRoute 314 !this._wasDrawerOpenBeforeSettingsRoute &&
304 && this.isWorkspaceDrawerOpen 315 this.isWorkspaceDrawerOpen
305 ) { 316 ) {
306 workspaceActions.toggleWorkspaceDrawer(); 317 workspaceActions.toggleWorkspaceDrawer();
307 } 318 }
@@ -311,14 +322,15 @@ export default class WorkspacesStore extends FeatureStore {
311 _cleanupInvalidServiceReferences = () => { 322 _cleanupInvalidServiceReferences = () => {
312 const { services } = this.stores; 323 const { services } = this.stores;
313 const { allServicesRequest } = services; 324 const { allServicesRequest } = services;
314 const servicesHaveBeenLoaded = allServicesRequest.wasExecuted && !allServicesRequest.isError; 325 const servicesHaveBeenLoaded =
326 allServicesRequest.wasExecuted && !allServicesRequest.isError;
315 // Loop through all workspaces and remove invalid service ids (locally) 327 // Loop through all workspaces and remove invalid service ids (locally)
316 for (const workspace of this.workspaces) { 328 for (const workspace of this.workspaces) {
317 for (const serviceId of workspace.services) { 329 for (const serviceId of workspace.services) {
318 if ( 330 if (
319 servicesHaveBeenLoaded 331 servicesHaveBeenLoaded &&
320 && !services.one(serviceId) 332 !services.one(serviceId) &&
321 && serviceId !== KEEP_WS_LOADED_USID 333 serviceId !== KEEP_WS_LOADED_USID
322 ) { 334 ) {
323 workspace.services.remove(serviceId); 335 workspace.services.remove(serviceId);
324 } 336 }