From aa18d3b84ece4fbc864f6a4f4d3b84fbef564b48 Mon Sep 17 00:00:00 2001 From: vantezzen Date: Mon, 23 Sep 2019 20:18:01 +0200 Subject: Fix lint --- src/components/services/content/ServiceWebview.js | 20 +++++++++++++++++++- src/features/quickSwitch/Component.js | 3 +++ src/i18n/locales/defaultMessages.json | 8 ++++---- .../messages/src/features/quickSwitch/Component.json | 8 ++++---- src/webview/recipe.js | 2 +- 5 files changed, 31 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/components/services/content/ServiceWebview.js b/src/components/services/content/ServiceWebview.js index 7252c695f..75b3d2cf0 100644 --- a/src/components/services/content/ServiceWebview.js +++ b/src/components/services/content/ServiceWebview.js @@ -1,10 +1,13 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { observer } from 'mobx-react'; +import { observable, reaction } from 'mobx'; import ElectronWebView from 'react-electron-web-view'; import ServiceModel from '../../../models/Service'; +const debug = require('debug')('Ferdi:Services'); + @observer class ServiceWebview extends Component { static propTypes = { @@ -13,7 +16,22 @@ class ServiceWebview extends Component { detachService: PropTypes.func.isRequired, }; - webview = null; + @observable webview = null; + + constructor(props) { + super(props); + + reaction( + () => this.webview, + () => { + if (this.webview.view) { + this.webview.view.addEventListener('console-message', (e) => { + debug('Service logged a message:', e.message); + }); + } + }, + ); + } componentWillUnmount() { const { service, detachService } = this.props; diff --git a/src/features/quickSwitch/Component.js b/src/features/quickSwitch/Component.js index 3217a3d93..ddbdbe304 100644 --- a/src/features/quickSwitch/Component.js +++ b/src/features/quickSwitch/Component.js @@ -1,4 +1,5 @@ import React, { Component, createRef } from 'react'; +import { remote } from 'electron'; import PropTypes from 'prop-types'; import { observer, inject } from 'mobx-react'; import { reaction } from 'mobx'; @@ -190,6 +191,8 @@ export default @injectSheet(styles) @inject('stores', 'actions') @observer class if (isModalVisible && !this.state.wasPrevVisible) { // Set focus back on current window if its in a service // TODO: Find a way to gain back focus + remote.getCurrentWindow().blurWebView(); + remote.getCurrentWindow().webContents.focus(); // The input "focus" attribute will only work on first modal open // Manually add focus to the input element diff --git a/src/i18n/locales/defaultMessages.json b/src/i18n/locales/defaultMessages.json index de1712048..ccb81a9f3 100644 --- a/src/i18n/locales/defaultMessages.json +++ b/src/i18n/locales/defaultMessages.json @@ -4167,26 +4167,26 @@ "defaultMessage": "!!!Search...", "end": { "column": 3, - "line": 17 + "line": 18 }, "file": "src/features/quickSwitch/Component.js", "id": "feature.quickSwitch.search", "start": { "column": 10, - "line": 14 + "line": 15 } }, { "defaultMessage": "!!!Select a service with TAB, ↑ and ↓. Open a service with ENTER.", "end": { "column": 3, - "line": 21 + "line": 22 }, "file": "src/features/quickSwitch/Component.js", "id": "feature.quickSwitch.info", "start": { "column": 8, - "line": 18 + "line": 19 } } ], diff --git a/src/i18n/messages/src/features/quickSwitch/Component.json b/src/i18n/messages/src/features/quickSwitch/Component.json index 248925a37..f42e1af49 100644 --- a/src/i18n/messages/src/features/quickSwitch/Component.json +++ b/src/i18n/messages/src/features/quickSwitch/Component.json @@ -4,11 +4,11 @@ "defaultMessage": "!!!Search...", "file": "src/features/quickSwitch/Component.js", "start": { - "line": 14, + "line": 15, "column": 10 }, "end": { - "line": 17, + "line": 18, "column": 3 } }, @@ -17,11 +17,11 @@ "defaultMessage": "!!!Select a service with TAB, ↑ and ↓. Open a service with ENTER.", "file": "src/features/quickSwitch/Component.js", "start": { - "line": 18, + "line": 19, "column": 8 }, "end": { - "line": 21, + "line": 22, "column": 3 } } diff --git a/src/webview/recipe.js b/src/webview/recipe.js index e97013b3c..fca00fde2 100644 --- a/src/webview/recipe.js +++ b/src/webview/recipe.js @@ -114,7 +114,7 @@ class RecipeController { } } - if (this.settings.service.isDarkModeEnabled || this.settings.app.darkMode) { + if (this.settings.service.isDarkModeEnabled || this.settings.app.darkMode) { debug('Enable dark mode'); // Check if recipe has a darkmode.css -- cgit v1.2.3-70-g09d2