diff options
author | 2019-09-17 12:20:57 +0200 | |
---|---|---|
committer | 2019-09-17 12:20:57 +0200 | |
commit | 4ec6e8625e9a1ea995cd1557a06c17ef0b0774bd (patch) | |
tree | 702a4a712e18befb543389aee4aabf308de03846 /src/stores | |
parent | Implement #41 (diff) | |
parent | Merge pull request #44 from kytwb/issue-37 (diff) | |
download | ferdium-app-4ec6e8625e9a1ea995cd1557a06c17ef0b0774bd.tar.gz ferdium-app-4ec6e8625e9a1ea995cd1557a06c17ef0b0774bd.tar.zst ferdium-app-4ec6e8625e9a1ea995cd1557a06c17ef0b0774bd.zip |
Merge branch 'master' into issue-41
Diffstat (limited to 'src/stores')
-rw-r--r-- | src/stores/ServicesStore.js | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 374daf333..f88b14983 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -14,6 +14,7 @@ import { matchRoute } from '../helpers/routing-helpers'; | |||
14 | import { workspaceStore } from '../features/workspaces'; | 14 | import { workspaceStore } from '../features/workspaces'; |
15 | import { serviceLimitStore } from '../features/serviceLimit'; | 15 | import { serviceLimitStore } from '../features/serviceLimit'; |
16 | import { RESTRICTION_TYPES } from '../models/Service'; | 16 | import { RESTRICTION_TYPES } from '../models/Service'; |
17 | import { KEEP_WS_LOADED_USID } from '../config'; | ||
17 | 18 | ||
18 | const debug = require('debug')('Ferdi:ServiceStore'); | 19 | const debug = require('debug')('Ferdi:ServiceStore'); |
19 | 20 | ||
@@ -124,7 +125,35 @@ export default class ServicesStore extends Store { | |||
124 | const { keepAllWorkspacesLoaded } = this.stores.workspaces.settings; | 125 | const { keepAllWorkspacesLoaded } = this.stores.workspaces.settings; |
125 | const services = this.allServicesRequest.execute().result || []; | 126 | const services = this.allServicesRequest.execute().result || []; |
126 | const filteredServices = showDisabledServices ? services : services.filter(service => service.isEnabled); | 127 | const filteredServices = showDisabledServices ? services : services.filter(service => service.isEnabled); |
127 | return keepAllWorkspacesLoaded ? filteredServices : workspaceStore.filterServicesByActiveWorkspace(filteredServices); | 128 | |
129 | let displayedServices; | ||
130 | if (keepAllWorkspacesLoaded) { | ||
131 | // Keep all enabled services loaded | ||
132 | displayedServices = filteredServices; | ||
133 | } else { | ||
134 | // Keep all services in current workspace loaded | ||
135 | displayedServices = workspaceStore.filterServicesByActiveWorkspace(filteredServices); | ||
136 | |||
137 | // Keep all services active in workspaces that should be kept loaded | ||
138 | for (const workspace of this.stores.workspaces.workspaces) { | ||
139 | // Check if workspace needs to be kept loaded | ||
140 | if (workspace.services.includes(KEEP_WS_LOADED_USID)) { | ||
141 | // Get services for workspace | ||
142 | const serviceIDs = workspace.services.filter(i => i !== KEEP_WS_LOADED_USID); | ||
143 | const wsServices = filteredServices.filter(service => serviceIDs.includes(service.id)); | ||
144 | |||
145 | displayedServices = [ | ||
146 | ...displayedServices, | ||
147 | ...wsServices, | ||
148 | ]; | ||
149 | } | ||
150 | } | ||
151 | |||
152 | // Make sure every service is in the list only once | ||
153 | displayedServices = displayedServices.filter((v, i, a) => a.indexOf(v) === i); | ||
154 | } | ||
155 | |||
156 | return displayedServices; | ||
128 | } | 157 | } |
129 | 158 | ||
130 | @computed get filtered() { | 159 | @computed get filtered() { |