From b37a6b07b39c8c7827052dc6fb97f490f1e0f514 Mon Sep 17 00:00:00 2001 From: Markus Hatvan Date: Thu, 18 Nov 2021 17:37:45 +0100 Subject: chore: convert various files to TS (#2246) * convert various files to TS * removed outdated docs/example-feature folder * turn off unicorn/no-empty-file * update eslint config --- src/stores/ServicesStore.js | 56 +++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 27 deletions(-) (limited to 'src/stores/ServicesStore.js') diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 16deb91c5..3d418c4c5 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js @@ -655,20 +655,20 @@ export default class ServicesStore extends Store { @action _setWebviewReference({ serviceId, webview }) { const service = this.one(serviceId); - - service.webview = webview; - - if (!service.isAttached) { - debug('Webview is not attached, initializing'); - service.initializeWebViewEvents({ - handleIPCMessage: this.actions.service.handleIPCMessage, - openWindow: this.actions.service.openWindow, - stores: this.stores, - }); - service.initializeWebViewListener(); + if (service) { + service.webview = webview; + + if (!service.isAttached) { + debug('Webview is not attached, initializing'); + service.initializeWebViewEvents({ + handleIPCMessage: this.actions.service.handleIPCMessage, + openWindow: this.actions.service.openWindow, + stores: this.stores, + }); + service.initializeWebViewListener(); + } + service.isAttached = true; } - - service.isAttached = true; } @action _detachService({ service }) { @@ -690,20 +690,22 @@ 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(() => { - document - .querySelector('.services__webview-wrapper.is-active') - .scrollIntoView({ - behavior: 'smooth', - block: 'end', - inline: 'nearest', - }); - }, 10); + if (service._webview) { + 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(() => { + document + .querySelector('.services__webview-wrapper.is-active') + .scrollIntoView({ + behavior: 'smooth', + block: 'end', + inline: 'nearest', + }); + }, 10); + } } } else { debug('No service is active'); -- cgit v1.2.3-54-g00ecf