aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/ServicesStore.js
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-11-09 12:11:16 +0100
committerLibravatar Stefan Malzner <stefan@adlk.io>2017-11-09 12:15:36 +0100
commit1839eff4fcad186871672499b6c3cc68e9539ce2 (patch)
tree207f0c0cf694309f6d84afeee220cacdc9b56242 /src/stores/ServicesStore.js
parentMerge branch 'develop' of github.com:meetfranz/franz into develop (diff)
downloadferdium-app-1839eff4fcad186871672499b6c3cc68e9539ce2.tar.gz
ferdium-app-1839eff4fcad186871672499b6c3cc68e9539ce2.tar.zst
ferdium-app-1839eff4fcad186871672499b6c3cc68e9539ce2.zip
feat(Service): Add option to display disabled services in tabs
Diffstat (limited to 'src/stores/ServicesStore.js')
-rw-r--r--src/stores/ServicesStore.js34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js
index 1d895d532..6c41c22cf 100644
--- a/src/stores/ServicesStore.js
+++ b/src/stores/ServicesStore.js
@@ -78,6 +78,10 @@ export default class ServicesStore extends Store {
78 return this.all.filter(service => service.isEnabled); 78 return this.all.filter(service => service.isEnabled);
79 } 79 }
80 80
81 @computed get allDisplayed() {
82 return this.stores.settings.all.showDisabledServices ? this.all : this.enabled;
83 }
84
81 @computed get filtered() { 85 @computed get filtered() {
82 return this.all.filter(service => service.name.toLowerCase().includes(this.filterNeedle.toLowerCase())); 86 return this.all.filter(service => service.name.toLowerCase().includes(this.filterNeedle.toLowerCase()));
83 } 87 }
@@ -208,21 +212,23 @@ export default class ServicesStore extends Store {
208 } 212 }
209 213
210 @action _setActiveNext() { 214 @action _setActiveNext() {
211 const nextIndex = this._wrapIndex(this.enabled.findIndex(service => service.isActive), 1, this.enabled.length); 215 const nextIndex = this._wrapIndex(this.allDisplayed.findIndex(service => service.isActive), 1, this.allDisplayed.length);
212 216
217 // TODO: simplify this;
213 this.all.forEach((s, index) => { 218 this.all.forEach((s, index) => {
214 this.all[index].isActive = false; 219 this.all[index].isActive = false;
215 }); 220 });
216 this.enabled[nextIndex].isActive = true; 221 this.allDisplayed[nextIndex].isActive = true;
217 } 222 }
218 223
219 @action _setActivePrev() { 224 @action _setActivePrev() {
220 const prevIndex = this._wrapIndex(this.enabled.findIndex(service => service.isActive), -1, this.enabled.length); 225 const prevIndex = this._wrapIndex(this.allDisplayed.findIndex(service => service.isActive), -1, this.allDisplayed.length);
221 226
227 // TODO: simplify this;
222 this.all.forEach((s, index) => { 228 this.all.forEach((s, index) => {
223 this.all[index].isActive = false; 229 this.all[index].isActive = false;
224 }); 230 });
225 this.enabled[prevIndex].isActive = true; 231 this.allDisplayed[prevIndex].isActive = true;
226 } 232 }
227 233
228 @action _setUnreadMessageCount({ serviceId, count }) { 234 @action _setUnreadMessageCount({ serviceId, count }) {
@@ -373,9 +379,9 @@ export default class ServicesStore extends Store {
373 } 379 }
374 380
375 @action _reorder({ oldIndex, newIndex }) { 381 @action _reorder({ oldIndex, newIndex }) {
376 const oldEnabledSortIndex = this.all.indexOf(this.enabled[oldIndex]); 382 const showDisabledServices = this.stores.settings.all.showDisabledServices;
377 const newEnabledSortIndex = this.all.indexOf(this.enabled[newIndex]); 383 const oldEnabledSortIndex = showDisabledServices ? oldIndex : this.all.indexOf(this.enabled[oldIndex]);
378 384 const newEnabledSortIndex = showDisabledServices ? newIndex : this.all.indexOf(this.enabled[newIndex]);
379 385
380 this.all.splice(newEnabledSortIndex, 0, this.all.splice(oldEnabledSortIndex, 1)[0]); 386 this.all.splice(newEnabledSortIndex, 0, this.all.splice(oldEnabledSortIndex, 1)[0]);
381 387
@@ -444,19 +450,11 @@ export default class ServicesStore extends Store {
444 450
445 _mapActiveServiceToServiceModelReaction() { 451 _mapActiveServiceToServiceModelReaction() {
446 const { activeService } = this.stores.settings.all; 452 const { activeService } = this.stores.settings.all;
447 const services = this.enabled; 453 if (this.allDisplayed.length) {
448 if (services.length) { 454 this.allDisplayed.map(service => Object.assign(service, {
449 services.map(service => Object.assign(service, { 455 isActive: activeService ? activeService === service.id : this.allDisplayed[0].id === service.id,
450 isActive: activeService ? activeService === service.id : services[0].id === service.id,
451 })); 456 }));
452
453 // if (!services.active) {
454 //
455 // }
456 } 457 }
457 // else if (!activeService && services.length) {
458 // services[0].isActive = true;
459 // }
460 } 458 }
461 459
462 _getUnreadMessageCountReaction() { 460 _getUnreadMessageCountReaction() {