aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/ServicesStore.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores/ServicesStore.js')
-rw-r--r--src/stores/ServicesStore.js88
1 files changed, 42 insertions, 46 deletions
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js
index 926ee36f0..e546850f9 100644
--- a/src/stores/ServicesStore.js
+++ b/src/stores/ServicesStore.js
@@ -171,6 +171,13 @@ export default class ServicesStore extends Store {
171 ); 171 );
172 172
173 reaction( 173 reaction(
174 () => this.stores.settings.app.splitColumns,
175 () => {
176 this._shareSettingsWithServiceProcess();
177 },
178 );
179
180 reaction(
174 () => this.stores.settings.app.searchEngine, 181 () => this.stores.settings.app.searchEngine,
175 () => { 182 () => {
176 this._shareSettingsWithServiceProcess(); 183 this._shareSettingsWithServiceProcess();
@@ -580,7 +587,10 @@ export default class ServicesStore extends Store {
580 const service = this.one(serviceId); 587 const service = this.one(serviceId);
581 588
582 for (const s of this.all) { 589 for (const s of this.all) {
583 s.isActive = false; 590 if (s.isActive) {
591 s.lastUsed = Date.now();
592 s.isActive = false;
593 }
584 } 594 }
585 service.isActive = true; 595 service.isActive = true;
586 this._awake({ serviceId: service.id }); 596 this._awake({ serviceId: service.id });
@@ -617,12 +627,7 @@ export default class ServicesStore extends Store {
617 this.allDisplayed.length, 627 this.allDisplayed.length,
618 ); 628 );
619 629
620 for (const s of this.all) { 630 this._setActive({ serviceId: this.allDisplayed[nextIndex].id });
621 s.isActive = false;
622 }
623 this.allDisplayed[nextIndex].isActive = true;
624
625 this._focusActiveService();
626 } 631 }
627 632
628 @action _setActivePrev() { 633 @action _setActivePrev() {
@@ -632,12 +637,7 @@ export default class ServicesStore extends Store {
632 this.allDisplayed.length, 637 this.allDisplayed.length,
633 ); 638 );
634 639
635 for (const s of this.all) { 640 this._setActive({ serviceId: this.allDisplayed[prevIndex].id });
636 s.isActive = false;
637 }
638 this.allDisplayed[prevIndex].isActive = true;
639
640 this._focusActiveService();
641 } 641 }
642 642
643 @action _setUnreadMessageCount({ serviceId, count }) { 643 @action _setUnreadMessageCount({ serviceId, count }) {
@@ -655,20 +655,20 @@ export default class ServicesStore extends Store {
655 655
656 @action _setWebviewReference({ serviceId, webview }) { 656 @action _setWebviewReference({ serviceId, webview }) {
657 const service = this.one(serviceId); 657 const service = this.one(serviceId);
658 658 if (service) {
659 service.webview = webview; 659 service.webview = webview;
660 660
661 if (!service.isAttached) { 661 if (!service.isAttached) {
662 debug('Webview is not attached, initializing'); 662 debug('Webview is not attached, initializing');
663 service.initializeWebViewEvents({ 663 service.initializeWebViewEvents({
664 handleIPCMessage: this.actions.service.handleIPCMessage, 664 handleIPCMessage: this.actions.service.handleIPCMessage,
665 openWindow: this.actions.service.openWindow, 665 openWindow: this.actions.service.openWindow,
666 stores: this.stores, 666 stores: this.stores,
667 }); 667 });
668 service.initializeWebViewListener(); 668 service.initializeWebViewListener();
669 }
670 service.isAttached = true;
669 } 671 }
670
671 service.isAttached = true;
672 } 672 }
673 673
674 @action _detachService({ service }) { 674 @action _detachService({ service }) {
@@ -690,20 +690,22 @@ export default class ServicesStore extends Store {
690 // TODO: add checks to not focus service when router path is /settings or /auth 690 // TODO: add checks to not focus service when router path is /settings or /auth
691 const service = this.active; 691 const service = this.active;
692 if (service) { 692 if (service) {
693 document.title = `Ferdi - ${service.name} ${ 693 if (service._webview) {
694 service.dialogTitle ? ` - ${service.dialogTitle}` : '' 694 document.title = `Ferdi - ${service.name} ${
695 } ${service._webview ? `- ${service._webview.getTitle()}` : ''}`; 695 service.dialogTitle ? ` - ${service.dialogTitle}` : ''
696 this._focusService({ serviceId: service.id }); 696 } ${service._webview ? `- ${service._webview.getTitle()}` : ''}`;
697 if (this.stores.settings.app.splitMode && !focusEvent) { 697 this._focusService({ serviceId: service.id });
698 setTimeout(() => { 698 if (this.stores.settings.app.splitMode && !focusEvent) {
699 document 699 setTimeout(() => {
700 .querySelector('.services__webview-wrapper.is-active') 700 document
701 .scrollIntoView({ 701 .querySelector('.services__webview-wrapper.is-active')
702 behavior: 'smooth', 702 .scrollIntoView({
703 block: 'end', 703 behavior: 'smooth',
704 inline: 'nearest', 704 block: 'end',
705 }); 705 inline: 'nearest',
706 }, 10); 706 });
707 }, 10);
708 }
707 } 709 }
708 } else { 710 } else {
709 debug('No service is active'); 711 debug('No service is active');
@@ -797,8 +799,6 @@ export default class ServicesStore extends Store {
797 options.icon = '/assets/img/notification-badge.gif'; 799 options.icon = '/assets/img/notification-badge.gif';
798 } 800 }
799 801
800 console.log(title, options);
801
802 this.actions.app.notify({ 802 this.actions.app.notify({
803 notificationId: args[0].notificationId, 803 notificationId: args[0].notificationId,
804 title, 804 title,
@@ -1036,10 +1036,6 @@ export default class ServicesStore extends Store {
1036 if (!service.canHibernate) { 1036 if (!service.canHibernate) {
1037 return; 1037 return;
1038 } 1038 }
1039 if (service.isActive) {
1040 debug(`Skipping service hibernation for ${service.name}`);
1041 return;
1042 }
1043 1039
1044 debug(`Hibernate ${service.name}`); 1040 debug(`Hibernate ${service.name}`);
1045 1041