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