diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/features/quickSwitch/Component.js | 21 | ||||
-rw-r--r-- | src/stores/ServicesStore.js | 9 |
2 files changed, 28 insertions, 2 deletions
diff --git a/src/features/quickSwitch/Component.js b/src/features/quickSwitch/Component.js index 7b76553b2..583c7184c 100644 --- a/src/features/quickSwitch/Component.js +++ b/src/features/quickSwitch/Component.js | |||
@@ -119,10 +119,27 @@ export default @injectSheet(styles) @inject('stores', 'actions') @observer class | |||
119 | 119 | ||
120 | // Get currently shown services | 120 | // Get currently shown services |
121 | services() { | 121 | services() { |
122 | let services = this.props.stores.services.allDisplayed; | 122 | let services = []; |
123 | if (this.state.search) { | 123 | if (this.state.search) { |
124 | // Apply simple search algorythm | 124 | // Apply simple search algorythm to list of all services |
125 | services = this.props.stores.services.allDisplayed; | ||
125 | services = services.filter(service => service.name.toLowerCase().includes(this.state.search.toLowerCase())); | 126 | services = services.filter(service => service.name.toLowerCase().includes(this.state.search.toLowerCase())); |
127 | } else { | ||
128 | // Add last used services to services array | ||
129 | for (const service of this.props.stores.services.lastUsedServices) { | ||
130 | if (this.props.stores.services.one(service)) { | ||
131 | services.push( | ||
132 | this.props.stores.services.one(service), | ||
133 | ); | ||
134 | } | ||
135 | } | ||
136 | |||
137 | // Add all other services in the default order | ||
138 | for (const service of this.props.stores.services.allDisplayed) { | ||
139 | if (!services.includes(service)) { | ||
140 | services.push(service); | ||
141 | } | ||
142 | } | ||
126 | } | 143 | } |
127 | 144 | ||
128 | return services; | 145 | return services; |
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 076ecc204..6120ae023 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -34,6 +34,11 @@ export default class ServicesStore extends Store { | |||
34 | 34 | ||
35 | @observable filterNeedle = null; | 35 | @observable filterNeedle = null; |
36 | 36 | ||
37 | // Array of service IDs that have recently been used | ||
38 | // [0] => Most recent, [n] => Least recent | ||
39 | // No service ID should be in the list multiple times, not all service IDs have to be in the list | ||
40 | @observable lastUsedServices = []; | ||
41 | |||
37 | constructor(...args) { | 42 | constructor(...args) { |
38 | super(...args); | 43 | super(...args); |
39 | 44 | ||
@@ -325,6 +330,10 @@ export default class ServicesStore extends Store { | |||
325 | }); | 330 | }); |
326 | service.isActive = true; | 331 | service.isActive = true; |
327 | 332 | ||
333 | // Update list of last used services | ||
334 | this.lastUsedServices = this.lastUsedServices.filter(id => id !== serviceId); | ||
335 | this.lastUsedServices.unshift(serviceId); | ||
336 | |||
328 | this._focusActiveService(); | 337 | this._focusActiveService(); |
329 | } | 338 | } |
330 | 339 | ||