diff options
Diffstat (limited to 'src/stores/ServicesStore.js')
-rw-r--r-- | src/stores/ServicesStore.js | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index a20718eca..269cd1526 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -79,6 +79,10 @@ export default class ServicesStore extends Store { | |||
79 | return this.all.filter(service => service.isEnabled); | 79 | return this.all.filter(service => service.isEnabled); |
80 | } | 80 | } |
81 | 81 | ||
82 | @computed get allDisplayed() { | ||
83 | return this.stores.settings.all.showDisabledServices ? this.all : this.enabled; | ||
84 | } | ||
85 | |||
82 | @computed get filtered() { | 86 | @computed get filtered() { |
83 | return this.all.filter(service => service.name.toLowerCase().includes(this.filterNeedle.toLowerCase())); | 87 | return this.all.filter(service => service.name.toLowerCase().includes(this.filterNeedle.toLowerCase())); |
84 | } | 88 | } |
@@ -209,21 +213,23 @@ export default class ServicesStore extends Store { | |||
209 | } | 213 | } |
210 | 214 | ||
211 | @action _setActiveNext() { | 215 | @action _setActiveNext() { |
212 | const nextIndex = this._wrapIndex(this.enabled.findIndex(service => service.isActive), 1, this.enabled.length); | 216 | const nextIndex = this._wrapIndex(this.allDisplayed.findIndex(service => service.isActive), 1, this.allDisplayed.length); |
213 | 217 | ||
218 | // TODO: simplify this; | ||
214 | this.all.forEach((s, index) => { | 219 | this.all.forEach((s, index) => { |
215 | this.all[index].isActive = false; | 220 | this.all[index].isActive = false; |
216 | }); | 221 | }); |
217 | this.enabled[nextIndex].isActive = true; | 222 | this.allDisplayed[nextIndex].isActive = true; |
218 | } | 223 | } |
219 | 224 | ||
220 | @action _setActivePrev() { | 225 | @action _setActivePrev() { |
221 | const prevIndex = this._wrapIndex(this.enabled.findIndex(service => service.isActive), -1, this.enabled.length); | 226 | const prevIndex = this._wrapIndex(this.allDisplayed.findIndex(service => service.isActive), -1, this.allDisplayed.length); |
222 | 227 | ||
228 | // TODO: simplify this; | ||
223 | this.all.forEach((s, index) => { | 229 | this.all.forEach((s, index) => { |
224 | this.all[index].isActive = false; | 230 | this.all[index].isActive = false; |
225 | }); | 231 | }); |
226 | this.enabled[prevIndex].isActive = true; | 232 | this.allDisplayed[prevIndex].isActive = true; |
227 | } | 233 | } |
228 | 234 | ||
229 | @action _setUnreadMessageCount({ serviceId, count }) { | 235 | @action _setUnreadMessageCount({ serviceId, count }) { |
@@ -374,9 +380,9 @@ export default class ServicesStore extends Store { | |||
374 | } | 380 | } |
375 | 381 | ||
376 | @action _reorder({ oldIndex, newIndex }) { | 382 | @action _reorder({ oldIndex, newIndex }) { |
377 | const oldEnabledSortIndex = this.all.indexOf(this.enabled[oldIndex]); | 383 | const showDisabledServices = this.stores.settings.all.showDisabledServices; |
378 | const newEnabledSortIndex = this.all.indexOf(this.enabled[newIndex]); | 384 | const oldEnabledSortIndex = showDisabledServices ? oldIndex : this.all.indexOf(this.enabled[oldIndex]); |
379 | 385 | const newEnabledSortIndex = showDisabledServices ? newIndex : this.all.indexOf(this.enabled[newIndex]); | |
380 | 386 | ||
381 | this.all.splice(newEnabledSortIndex, 0, this.all.splice(oldEnabledSortIndex, 1)[0]); | 387 | this.all.splice(newEnabledSortIndex, 0, this.all.splice(oldEnabledSortIndex, 1)[0]); |
382 | 388 | ||
@@ -459,19 +465,11 @@ export default class ServicesStore extends Store { | |||
459 | 465 | ||
460 | _mapActiveServiceToServiceModelReaction() { | 466 | _mapActiveServiceToServiceModelReaction() { |
461 | const { activeService } = this.stores.settings.all; | 467 | const { activeService } = this.stores.settings.all; |
462 | const services = this.enabled; | 468 | if (this.allDisplayed.length) { |
463 | if (services.length) { | 469 | this.allDisplayed.map(service => Object.assign(service, { |
464 | services.map(service => Object.assign(service, { | 470 | isActive: activeService ? activeService === service.id : this.allDisplayed[0].id === service.id, |
465 | isActive: activeService ? activeService === service.id : services[0].id === service.id, | ||
466 | })); | 471 | })); |
467 | |||
468 | // if (!services.active) { | ||
469 | // | ||
470 | // } | ||
471 | } | 472 | } |
472 | // else if (!activeService && services.length) { | ||
473 | // services[0].isActive = true; | ||
474 | // } | ||
475 | } | 473 | } |
476 | 474 | ||
477 | _getUnreadMessageCountReaction() { | 475 | _getUnreadMessageCountReaction() { |