aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/quickSwitch/Component.js
diff options
context:
space:
mode:
authorLibravatar vantezzen <hello@vantezzen.io>2019-10-13 11:40:22 +0200
committerLibravatar vantezzen <hello@vantezzen.io>2019-10-13 11:40:22 +0200
commiteb71f7118644846b7b443bd632a7ebef71d8db1f (patch)
tree6ababc500e7f7e183e84c25475fccd89e1dbb4df /src/features/quickSwitch/Component.js
parentPartly fixing #115 (diff)
downloadferdium-app-eb71f7118644846b7b443bd632a7ebef71d8db1f.tar.gz
ferdium-app-eb71f7118644846b7b443bd632a7ebef71d8db1f.tar.zst
ferdium-app-eb71f7118644846b7b443bd632a7ebef71d8db1f.zip
Sort services in QuickSwitch by last used
Diffstat (limited to 'src/features/quickSwitch/Component.js')
-rw-r--r--src/features/quickSwitch/Component.js21
1 files changed, 19 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;