aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/ServicesStore.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores/ServicesStore.ts')
-rw-r--r--src/stores/ServicesStore.ts21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/stores/ServicesStore.ts b/src/stores/ServicesStore.ts
index 7812d5aee..83ec7d18e 100644
--- a/src/stores/ServicesStore.ts
+++ b/src/stores/ServicesStore.ts
@@ -618,6 +618,10 @@ export default class ServicesStore extends TypedStore {
618 await request._promise; 618 await request._promise;
619 } 619 }
620 620
621 @action _setIsActive(service: Service, state: boolean): void {
622 service.isActive = state;
623 }
624
621 @action _setActive({ serviceId, keepActiveRoute = null }) { 625 @action _setActive({ serviceId, keepActiveRoute = null }) {
622 if (!keepActiveRoute) this.stores.router.push('/'); 626 if (!keepActiveRoute) this.stores.router.push('/');
623 const service = this.one(serviceId); 627 const service = this.one(serviceId);
@@ -625,10 +629,10 @@ export default class ServicesStore extends TypedStore {
625 for (const s of this.all) { 629 for (const s of this.all) {
626 if (s.isActive) { 630 if (s.isActive) {
627 s.lastUsed = Date.now(); 631 s.lastUsed = Date.now();
628 s.isActive = false; 632 this._setIsActive(s, false);
629 } 633 }
630 } 634 }
631 service.isActive = true; 635 this._setIsActive(service, true);
632 this._awake({ serviceId: service.id }); 636 this._awake({ serviceId: service.id });
633 637
634 if ( 638 if (
@@ -650,7 +654,7 @@ export default class ServicesStore extends TypedStore {
650 @action _blurActive() { 654 @action _blurActive() {
651 const service = this.active; 655 const service = this.active;
652 if (service) { 656 if (service) {
653 service.isActive = false; 657 this._setIsActive(service, false);
654 } else { 658 } else {
655 debug('No service is active'); 659 debug('No service is active');
656 } 660 }
@@ -1194,13 +1198,14 @@ export default class ServicesStore extends TypedStore {
1194 _mapActiveServiceToServiceModelReaction() { 1198 _mapActiveServiceToServiceModelReaction() {
1195 const { activeService } = this.stores.settings.all.service; 1199 const { activeService } = this.stores.settings.all.service;
1196 if (this.allDisplayed.length > 0) { 1200 if (this.allDisplayed.length > 0) {
1197 this.allDisplayed.map(service => 1201 for (const service of this.allDisplayed) {
1198 Object.assign(service, { 1202 this._setIsActive(
1199 isActive: activeService 1203 service,
1204 activeService
1200 ? activeService === service.id 1205 ? activeService === service.id
1201 : this.allDisplayed[0].id === service.id, 1206 : this.allDisplayed[0].id === service.id,
1202 }), 1207 );
1203 ); 1208 }
1204 } 1209 }
1205 } 1210 }
1206 1211