From 1801f98f8e2ca28619608b29bcf623581fa76747 Mon Sep 17 00:00:00 2001 From: Chandrika Priya Bogadi <46720139+Chandrika-Priya@users.noreply.github.com> Date: Tue, 26 Oct 2021 23:03:36 +0530 Subject: Add feature to display document title along with current title (#2143) Co-authored by: Rachel Cynthia --- src/components/services/content/ServiceWebview.js | 20 +++++++++++++++----- src/stores/ServicesStore.js | 5 ++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/components/services/content/ServiceWebview.js b/src/components/services/content/ServiceWebview.js index 185d41175..2562c09ce 100644 --- a/src/components/services/content/ServiceWebview.js +++ b/src/components/services/content/ServiceWebview.js @@ -30,9 +30,14 @@ class ServiceWebview extends Component { this.webview.view.addEventListener('console-message', e => { debug('Service logged a message:', e.message); }); + this.webview.view.addEventListener('did-navigate', () => { + document.title = `Ferdi - ${this.props.service.name} ${this.props.service.dialogTitle + ? ` - ${this.props.service.dialogTitle}` + : '' + } ${`- ${this.props.service._webview.getTitle()}`}`; + }) } - }, - ); + }) } componentWillUnmount() { @@ -47,6 +52,12 @@ class ServiceWebview extends Component { if (this.props.service.isActive) { webview.view.blur(); webview.view.focus(); + window.setTimeout(() => { + document.title = `Ferdi - ${this.props.service.name} ${this.props.service.dialogTitle + ? ` - ${this.props.service.dialogTitle}` + : '' + } ${`- ${this.props.service._webview.getTitle()}`}`; + }, 100); } else { debug('Refocus not required - Not active service'); } @@ -92,9 +103,8 @@ class ServiceWebview extends Component { } allowpopups nodeintegration - webpreferences={`spellcheck=${ - isSpellcheckerEnabled ? 1 : 0 - }, contextIsolation=1, enableRemoteModule=1`} + webpreferences={`spellcheck=${isSpellcheckerEnabled ? 1 : 0 + }, contextIsolation=1, enableRemoteModule=1`} /> ); } diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index e52d661f3..926ee36f0 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js @@ -690,6 +690,9 @@ export default class ServicesStore extends Store { // TODO: add checks to not focus service when router path is /settings or /auth const service = this.active; if (service) { + document.title = `Ferdi - ${service.name} ${ + service.dialogTitle ? ` - ${service.dialogTitle}` : '' + } ${service._webview ? `- ${service._webview.getTitle()}` : ''}`; this._focusService({ serviceId: service.id }); if (this.stores.settings.app.splitMode && !focusEvent) { setTimeout(() => { @@ -1082,7 +1085,7 @@ export default class ServicesStore extends Store { this.actions.service.focusService({ serviceId: service.id }); document.title = `Ferdi - ${service.name} ${ service.dialogTitle ? ` - ${service.dialogTitle}` : '' - }`; + } ${service._webview ? `- ${service._webview.getTitle()}` : ''}`; } else { debug('No service is active'); } -- cgit v1.2.3-70-g09d2