diff options
author | Kristóf Marussy <kristof@marussy.com> | 2022-04-23 01:59:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-22 23:59:21 +0000 |
commit | d02644f7c41150709795e57bfd40351b4da35a7b (patch) | |
tree | 2403fb76bd5fae1703f8b55172ffce9e0a5d2bce /src/webview/notifications.ts | |
parent | Complete tray icons redesign for all platforms (#28) (diff) | |
download | ferdium-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/webview/notifications.ts')
-rw-r--r-- | src/webview/notifications.ts | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/webview/notifications.ts b/src/webview/notifications.ts index ff9c844d0..8b2831754 100644 --- a/src/webview/notifications.ts +++ b/src/webview/notifications.ts | |||
@@ -2,8 +2,7 @@ import { ipcRenderer } from 'electron'; | |||
2 | 2 | ||
3 | import { v1 as uuidV1 } from 'uuid'; | 3 | import { v1 as uuidV1 } from 'uuid'; |
4 | 4 | ||
5 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed | 5 | const debug = require('../preload-safe-debug')('Ferdium:Notifications'); |
6 | // const debug = require('debug')('Ferdium:Notifications'); | ||
7 | 6 | ||
8 | export class NotificationsHandler { | 7 | export class NotificationsHandler { |
9 | onNotify = (data: { title: string; options: any; notificationId: string }) => | 8 | onNotify = (data: { title: string; options: any; notificationId: string }) => |
@@ -11,7 +10,7 @@ export class NotificationsHandler { | |||
11 | 10 | ||
12 | displayNotification(title: string, options: any) { | 11 | displayNotification(title: string, options: any) { |
13 | return new Promise(resolve => { | 12 | return new Promise(resolve => { |
14 | console.log('New notification', title, options); | 13 | debug('New notification', title, options); |
15 | 14 | ||
16 | const notificationId = uuidV1(); | 15 | const notificationId = uuidV1(); |
17 | 16 | ||