aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/services
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-04-23 01:59:21 +0200
committerLibravatar GitHub <noreply@github.com>2022-04-22 23:59:21 +0000
commitd02644f7c41150709795e57bfd40351b4da35a7b (patch)
tree2403fb76bd5fae1703f8b55172ffce9e0a5d2bce /src/components/services
parentComplete tray icons redesign for all platforms (#28) (diff)
downloadferdium-app-d02644f7c41150709795e57bfd40351b4da35a7b.tar.gz
ferdium-app-d02644f7c41150709795e57bfd40351b4da35a7b.tar.zst
ferdium-app-d02644f7c41150709795e57bfd40351b4da35a7b.zip
Preload safe debug shim (#29)
In https://github.com/ferdium/ferdium-app/pull/23 we removed usages of the debug package due to an electron bug. This patch aims to restore some debug functionality by introducing a shim. The shim detect whether if it is being introduced in a preload script where the electron but would be triggered, and falls back to a simple replacement for debug. However, in the main and renderer processes, where a preload script is not being used, we still get full debug functionality. In this way, a module can be used both in a preload script and outside of it, while still preserving debug functionality whenever possible. Signed-off-by: Kristóf Marussy <kristof@marussy.com>
Diffstat (limited to 'src/components/services')
-rw-r--r--src/components/services/content/ServiceWebview.js9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/components/services/content/ServiceWebview.js b/src/components/services/content/ServiceWebview.js
index f1c4251ba..6d6089793 100644
--- a/src/components/services/content/ServiceWebview.js
+++ b/src/components/services/content/ServiceWebview.js
@@ -7,8 +7,7 @@ import { join } from 'path';
7 7
8import ServiceModel from '../../../models/Service'; 8import ServiceModel from '../../../models/Service';
9 9
10// TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed 10const debug = require('../../../preload-safe-debug')('Ferdium:Services');
11// const debug = require('debug')('Ferdium:Services');
12 11
13class ServiceWebview extends Component { 12class ServiceWebview extends Component {
14 static propTypes = { 13 static propTypes = {
@@ -28,7 +27,7 @@ class ServiceWebview extends Component {
28 () => { 27 () => {
29 if (this.webview && this.webview.view) { 28 if (this.webview && this.webview.view) {
30 this.webview.view.addEventListener('console-message', e => { 29 this.webview.view.addEventListener('console-message', e => {
31 console.log('Service logged a message:', e.message); 30 debug('Service logged a message:', e.message);
32 }); 31 });
33 this.webview.view.addEventListener('did-navigate', () => { 32 this.webview.view.addEventListener('did-navigate', () => {
34 if (this.props.service._webview) { 33 if (this.props.service._webview) {
@@ -51,7 +50,7 @@ class ServiceWebview extends Component {
51 50
52 refocusWebview = () => { 51 refocusWebview = () => {
53 const { webview } = this; 52 const { webview } = this;
54 console.log('Refocus Webview is called', this.props.service); 53 debug('Refocus Webview is called', this.props.service);
55 if (!webview) return; 54 if (!webview) return;
56 if (this.props.service.isActive) { 55 if (this.props.service.isActive) {
57 webview.view.blur(); 56 webview.view.blur();
@@ -64,7 +63,7 @@ class ServiceWebview extends Component {
64 } ${`- ${this.props.service._webview.getTitle()}`}`; 63 } ${`- ${this.props.service._webview.getTitle()}`}`;
65 }, 100); 64 }, 100);
66 } else { 65 } else {
67 console.log('Refocus not required - Not active service'); 66 debug('Refocus not required - Not active service');
68 } 67 }
69 }; 68 };
70 69