From 4d02744dfab8a49075b82a5ddbdc02e08c7e8a66 Mon Sep 17 00:00:00 2001 From: Iaroslav Date: Sat, 23 Oct 2021 19:16:01 +0500 Subject: Add active dialog title feature (#2114) https://github.com/getferdi/ferdi/issues/1280 WhatsApp-like services can set active dialog title to the app title eg. Ferdi - WhatsApp - Contact Name --- src/stores/ServicesStore.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/stores') diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 4f7ad7442..e52d661f3 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js @@ -82,6 +82,7 @@ export default class ServicesStore extends Store { this.actions.service.setUnreadMessageCount.listen( this._setUnreadMessageCount.bind(this), ); + this.actions.service.setDialogTitle.listen(this._setDialogTitle.bind(this)); this.actions.service.openWindow.listen(this._openWindow.bind(this)); this.actions.service.filter.listen(this._filter.bind(this)); this.actions.service.resetFilter.listen(this._resetFilter.bind(this)); @@ -646,6 +647,12 @@ export default class ServicesStore extends Store { service.unreadIndirectMessageCount = count.indirect; } + @action _setDialogTitle({ serviceId, dialogTitle }) { + const service = this.one(serviceId); + + service.dialogTitle = dialogTitle; + } + @action _setWebviewReference({ serviceId, webview }) { const service = this.one(serviceId); @@ -741,6 +748,16 @@ export default class ServicesStore extends Store { break; } + case 'active-dialog-title': { + debug(`Received active dialog title from '${serviceId}'`, args[0]); + + this.actions.service.setDialogTitle({ + serviceId, + dialogTitle: args[0], + }); + + break; + } case 'notification': { const { options } = args[0]; @@ -1063,7 +1080,9 @@ export default class ServicesStore extends Store { const service = this.active; if (service) { this.actions.service.focusService({ serviceId: service.id }); - document.title = `Ferdi - ${service.name}`; + document.title = `Ferdi - ${service.name} ${ + service.dialogTitle ? ` - ${service.dialogTitle}` : '' + }`; } else { debug('No service is active'); } -- cgit v1.2.3-70-g09d2