diff options
author | Vijay Aravamudhan <vraravam@users.noreply.github.com> | 2022-04-22 15:04:21 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-22 20:04:21 +0000 |
commit | 759d93dc198a3cc8c5265245c0144efa5435682b (patch) | |
tree | 53e963a085d3d12af5a2efa2f1ab6f3e5574edc7 /src/stores/AppStore.js | |
parent | Added build scripts for linux, macos and windows to help new contributors get... (diff) | |
download | ferdium-app-759d93dc198a3cc8c5265245c0144efa5435682b.tar.gz ferdium-app-759d93dc198a3cc8c5265245c0144efa5435682b.tar.zst ferdium-app-759d93dc198a3cc8c5265245c0144efa5435682b.zip |
Turn off usage of 'debug' npm package using with electron-16 (fixes #17)
Diffstat (limited to 'src/stores/AppStore.js')
-rw-r--r-- | src/stores/AppStore.js | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 68796b692..55cdce5f2 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -29,7 +29,8 @@ import { | |||
29 | import { openExternalUrl } from '../helpers/url-helpers'; | 29 | import { openExternalUrl } from '../helpers/url-helpers'; |
30 | import { sleep } from '../helpers/async-helpers'; | 30 | import { sleep } from '../helpers/async-helpers'; |
31 | 31 | ||
32 | const debug = require('debug')('Ferdium:AppStore'); | 32 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
33 | // const debug = require('debug')('Ferdium:AppStore'); | ||
33 | 34 | ||
34 | const mainWindow = getCurrentWindow(); | 35 | const mainWindow = getCurrentWindow(); |
35 | 36 | ||
@@ -195,7 +196,7 @@ export default class AppStore extends Store { | |||
195 | 196 | ||
196 | // Handle deep linking (ferdium://) | 197 | // Handle deep linking (ferdium://) |
197 | ipcRenderer.on('navigateFromDeepLink', (event, data) => { | 198 | ipcRenderer.on('navigateFromDeepLink', (event, data) => { |
198 | debug('Navigate from deep link', data); | 199 | console.log('Navigate from deep link', data); |
199 | let { url } = data; | 200 | let { url } = data; |
200 | if (!url) return; | 201 | if (!url) return; |
201 | 202 | ||
@@ -217,28 +218,28 @@ export default class AppStore extends Store { | |||
217 | this.isSystemDarkModeEnabled = nativeTheme.shouldUseDarkColors; | 218 | this.isSystemDarkModeEnabled = nativeTheme.shouldUseDarkColors; |
218 | 219 | ||
219 | ipcRenderer.on('isWindowFocused', (event, isFocused) => { | 220 | ipcRenderer.on('isWindowFocused', (event, isFocused) => { |
220 | debug('Setting is focused to', isFocused); | 221 | console.log('Setting is focused to', isFocused); |
221 | this.isFocused = isFocused; | 222 | this.isFocused = isFocused; |
222 | }); | 223 | }); |
223 | 224 | ||
224 | powerMonitor.on('suspend', () => { | 225 | powerMonitor.on('suspend', () => { |
225 | debug('System suspended starting timer'); | 226 | console.log('System suspended starting timer'); |
226 | 227 | ||
227 | this.timeSuspensionStart = moment(); | 228 | this.timeSuspensionStart = moment(); |
228 | }); | 229 | }); |
229 | 230 | ||
230 | powerMonitor.on('resume', () => { | 231 | powerMonitor.on('resume', () => { |
231 | debug('System resumed, last suspended on', this.timeSuspensionStart); | 232 | console.log('System resumed, last suspended on', this.timeSuspensionStart); |
232 | this.actions.service.resetLastPollTimer(); | 233 | this.actions.service.resetLastPollTimer(); |
233 | 234 | ||
234 | if ( | 235 | if ( |
235 | this.timeSuspensionStart.add(10, 'm').isBefore(moment()) && | 236 | this.timeSuspensionStart.add(10, 'm').isBefore(moment()) && |
236 | this.stores.settings.app.get('reloadAfterResume') | 237 | this.stores.settings.app.get('reloadAfterResume') |
237 | ) { | 238 | ) { |
238 | debug('Reloading services, user info and features'); | 239 | console.log('Reloading services, user info and features'); |
239 | 240 | ||
240 | setInterval(() => { | 241 | setInterval(() => { |
241 | debug('Reload app interval is starting'); | 242 | console.log('Reload app interval is starting'); |
242 | if (this.isOnline) { | 243 | if (this.isOnline) { |
243 | window.location.reload(); | 244 | window.location.reload(); |
244 | } | 245 | } |
@@ -250,7 +251,7 @@ export default class AppStore extends Store { | |||
250 | // notifications got stuck after upgrade but forcing a notification | 251 | // notifications got stuck after upgrade but forcing a notification |
251 | // via `new Notification` triggered the permission request | 252 | // via `new Notification` triggered the permission request |
252 | if (isMac && !localStorage.getItem(CATALINA_NOTIFICATION_HACK_KEY)) { | 253 | if (isMac && !localStorage.getItem(CATALINA_NOTIFICATION_HACK_KEY)) { |
253 | debug('Triggering macOS Catalina notification permission trigger'); | 254 | console.log('Triggering macOS Catalina notification permission trigger'); |
254 | // eslint-disable-next-line no-new | 255 | // eslint-disable-next-line no-new |
255 | new window.Notification('Welcome to Ferdium 5', { | 256 | new window.Notification('Welcome to Ferdium 5', { |
256 | body: 'Have a wonderful day & happy messaging.', | 257 | body: 'Have a wonderful day & happy messaging.', |
@@ -319,7 +320,7 @@ export default class AppStore extends Store { | |||
319 | 320 | ||
320 | const notification = new window.Notification(title, options); | 321 | const notification = new window.Notification(title, options); |
321 | 322 | ||
322 | debug('New notification', title, options); | 323 | console.log('New notification', title, options); |
323 | 324 | ||
324 | notification.addEventListener('click', () => { | 325 | notification.addEventListener('click', () => { |
325 | if (serviceId) { | 326 | if (serviceId) { |
@@ -341,7 +342,7 @@ export default class AppStore extends Store { | |||
341 | } | 342 | } |
342 | mainWindow.focus(); | 343 | mainWindow.focus(); |
343 | 344 | ||
344 | debug('Notification click handler'); | 345 | console.log('Notification click handler'); |
345 | } | 346 | } |
346 | }); | 347 | }); |
347 | } | 348 | } |
@@ -370,10 +371,10 @@ export default class AppStore extends Store { | |||
370 | 371 | ||
371 | try { | 372 | try { |
372 | if (enable) { | 373 | if (enable) { |
373 | debug('enabling launch on startup', executablePath); | 374 | console.log('enabling launch on startup', executablePath); |
374 | autoLauncher.enable(); | 375 | autoLauncher.enable(); |
375 | } else { | 376 | } else { |
376 | debug('disabling launch on startup'); | 377 | console.log('disabling launch on startup'); |
377 | autoLauncher.disable(); | 378 | autoLauncher.disable(); |
378 | } | 379 | } |
379 | } catch (error) { | 380 | } catch (error) { |
@@ -388,7 +389,7 @@ export default class AppStore extends Store { | |||
388 | 389 | ||
389 | @action _checkForUpdates() { | 390 | @action _checkForUpdates() { |
390 | if (this.isOnline && this.stores.settings.app.automaticUpdates && (isMac || isWindows || process.env.APPIMAGE)) { | 391 | if (this.isOnline && this.stores.settings.app.automaticUpdates && (isMac || isWindows || process.env.APPIMAGE)) { |
391 | debug('_checkForUpdates: sending event to autoUpdate:check'); | 392 | console.log('_checkForUpdates: sending event to autoUpdate:check'); |
392 | this.updateStatus = this.updateStatusTypes.CHECKING; | 393 | this.updateStatus = this.updateStatusTypes.CHECKING; |
393 | ipcRenderer.send('autoUpdate', { | 394 | ipcRenderer.send('autoUpdate', { |
394 | action: 'check', | 395 | action: 'check', |
@@ -401,7 +402,7 @@ export default class AppStore extends Store { | |||
401 | } | 402 | } |
402 | 403 | ||
403 | @action _installUpdate() { | 404 | @action _installUpdate() { |
404 | debug('_installUpdate: sending event to autoUpdate:install'); | 405 | console.log('_installUpdate: sending event to autoUpdate:install'); |
405 | ipcRenderer.send('autoUpdate', { | 406 | ipcRenderer.send('autoUpdate', { |
406 | action: 'install', | 407 | action: 'install', |
407 | }); | 408 | }); |
@@ -487,7 +488,7 @@ export default class AppStore extends Store { | |||
487 | } | 488 | } |
488 | 489 | ||
489 | moment.locale(this.locale); | 490 | moment.locale(this.locale); |
490 | debug(`Set locale to "${this.locale}"`); | 491 | console.log(`Set locale to "${this.locale}"`); |
491 | } | 492 | } |
492 | 493 | ||
493 | _getDefaultLocale() { | 494 | _getDefaultLocale() { |
@@ -541,7 +542,7 @@ export default class AppStore extends Store { | |||
541 | this.autoLaunchOnStart = await this._checkAutoStart(); | 542 | this.autoLaunchOnStart = await this._checkAutoStart(); |
542 | 543 | ||
543 | if (this.stores.settings.all.stats.appStarts === 1) { | 544 | if (this.stores.settings.all.stats.appStarts === 1) { |
544 | debug('Set app to launch on start'); | 545 | console.log('Set app to launch on start'); |
545 | this.actions.app.launchOnStartup({ | 546 | this.actions.app.launchOnStartup({ |
546 | enable: true, | 547 | enable: true, |
547 | }); | 548 | }); |
@@ -553,9 +554,9 @@ export default class AppStore extends Store { | |||
553 | } | 554 | } |
554 | 555 | ||
555 | async _systemDND() { | 556 | async _systemDND() { |
556 | debug('Checking if Do Not Disturb Mode is on'); | 557 | console.log('Checking if Do Not Disturb Mode is on'); |
557 | const dnd = await ipcRenderer.invoke('get-dnd'); | 558 | const dnd = await ipcRenderer.invoke('get-dnd'); |
558 | debug('Do not disturb mode is', dnd); | 559 | console.log('Do not disturb mode is', dnd); |
559 | if ( | 560 | if ( |
560 | dnd !== this.stores.settings.all.app.isAppMuted && | 561 | dnd !== this.stores.settings.all.app.isAppMuted && |
561 | !this.isSystemMuteOverridden | 562 | !this.isSystemMuteOverridden |