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/stores/UserStore.js | |
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/stores/UserStore.js')
-rw-r--r-- | src/stores/UserStore.js | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js index 8c413a065..661c03e2c 100644 --- a/src/stores/UserStore.js +++ b/src/stores/UserStore.js | |||
@@ -10,8 +10,7 @@ import Store from './lib/Store'; | |||
10 | import Request from './lib/Request'; | 10 | import Request from './lib/Request'; |
11 | import CachedRequest from './lib/CachedRequest'; | 11 | import CachedRequest from './lib/CachedRequest'; |
12 | 12 | ||
13 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed | 13 | const debug = require('../preload-safe-debug')('Ferdium:UserStore'); |
14 | // const debug = require('debug')('Ferdium:UserStore'); | ||
15 | 14 | ||
16 | // TODO: split stores into UserStore and AuthStore | 15 | // TODO: split stores into UserStore and AuthStore |
17 | export default class UserStore extends Store { | 16 | export default class UserStore extends Store { |
@@ -395,7 +394,7 @@ export default class UserStore extends Store { | |||
395 | } | 394 | } |
396 | 395 | ||
397 | if (!this.data.locale) { | 396 | if (!this.data.locale) { |
398 | console.log('Migrate "locale" to user data'); | 397 | debug('Migrate "locale" to user data'); |
399 | this.actions.user.update({ | 398 | this.actions.user.update({ |
400 | userData: { | 399 | userData: { |
401 | locale: this.stores.app.locale, | 400 | locale: this.stores.app.locale, |