aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores
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/stores
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/stores')
-rw-r--r--src/stores/AppStore.js37
-rw-r--r--src/stores/RecipesStore.js11
-rw-r--r--src/stores/RequestStore.js5
-rw-r--r--src/stores/ServicesStore.js55
-rw-r--r--src/stores/SettingsStore.js11
-rw-r--r--src/stores/UserStore.js5
6 files changed, 59 insertions, 65 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 {
29import { openExternalUrl } from '../helpers/url-helpers'; 29import { openExternalUrl } from '../helpers/url-helpers';
30import { sleep } from '../helpers/async-helpers'; 30import { 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 32const debug = require('../preload-safe-debug')('Ferdium:AppStore');
33// const debug = require('debug')('Ferdium:AppStore');
34 33
35const mainWindow = getCurrentWindow(); 34const 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
diff --git a/src/stores/RecipesStore.js b/src/stores/RecipesStore.js
index d39b87401..3d3a506cc 100644
--- a/src/stores/RecipesStore.js
+++ b/src/stores/RecipesStore.js
@@ -8,8 +8,7 @@ import Request from './lib/Request';
8import { matchRoute } from '../helpers/routing-helpers'; 8import { matchRoute } from '../helpers/routing-helpers';
9import { asarRecipesPath } from '../helpers/asar-helpers'; 9import { asarRecipesPath } from '../helpers/asar-helpers';
10 10
11// TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed 11const debug = require('../preload-safe-debug')('Ferdium:RecipeStore');
12// const debug = require('debug')('Ferdium:RecipeStore');
13 12
14export default class RecipesStore extends Store { 13export default class RecipesStore extends Store {
15 @observable allRecipesRequest = new CachedRequest(this.api.recipes, 'all'); 14 @observable allRecipesRequest = new CachedRequest(this.api.recipes, 'all');
@@ -48,7 +47,7 @@ export default class RecipesStore extends Store {
48 return activeRecipe; 47 return activeRecipe;
49 } 48 }
50 49
51 console.log(`Recipe ${match.id} not installed`); 50 debug(`Recipe ${match.id} not installed`);
52 } 51 }
53 52
54 return null; 53 return null;
@@ -79,7 +78,7 @@ export default class RecipesStore extends Store {
79 const recipes = {}; 78 const recipes = {};
80 79
81 // Hackfix, reference this.all to fetch services 80 // Hackfix, reference this.all to fetch services
82 console.log(`Check Recipe updates for ${this.all.map(recipe => recipe.id)}`); 81 debug(`Check Recipe updates for ${this.all.map(recipe => recipe.id)}`);
83 82
84 for (const r of recipeIds) { 83 for (const r of recipeIds) {
85 const recipe = this.one(r); 84 const recipe = this.one(r);
@@ -108,7 +107,7 @@ export default class RecipesStore extends Store {
108 } 107 }
109 108
110 const updates = [...remoteUpdates, ...localUpdates]; 109 const updates = [...remoteUpdates, ...localUpdates];
111 console.log( 110 debug(
112 'Got update information (local, remote):', 111 'Got update information (local, remote):',
113 localUpdates, 112 localUpdates,
114 remoteUpdates, 113 remoteUpdates,
@@ -146,7 +145,7 @@ export default class RecipesStore extends Store {
146 145
147 if (!this.stores.recipes.isInstalled(recipeId)) { 146 if (!this.stores.recipes.isInstalled(recipeId)) {
148 router.push('/settings/recipes'); 147 router.push('/settings/recipes');
149 console.log(`Recipe ${recipeId} is not installed, trying to install it`); 148 debug(`Recipe ${recipeId} is not installed, trying to install it`);
150 149
151 const recipe = await this.installRecipeRequest.execute(recipeId) 150 const recipe = await this.installRecipeRequest.execute(recipeId)
152 ._promise; 151 ._promise;
diff --git a/src/stores/RequestStore.js b/src/stores/RequestStore.js
index a6991409c..8b716ac81 100644
--- a/src/stores/RequestStore.js
+++ b/src/stores/RequestStore.js
@@ -4,8 +4,7 @@ import ms from 'ms';
4 4
5import Store from './lib/Store'; 5import Store from './lib/Store';
6 6
7// TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed 7const debug = require('../preload-safe-debug')('Ferdium:RequestsStore');
8// const debug = require('debug')('Ferdium:RequestsStore');
9 8
10export default class RequestStore extends Store { 9export default class RequestStore extends Store {
11 @observable userInfoRequest; 10 @observable userInfoRequest;
@@ -66,7 +65,7 @@ export default class RequestStore extends Store {
66 } 65 }
67 66
68 this._autoRetry(); 67 this._autoRetry();
69 console.log(`Retry required requests delayed in ${delay / 1000}s`); 68 debug(`Retry required requests delayed in ${delay / 1000}s`);
70 }, delay); 69 }, delay);
71 } 70 }
72 } 71 }
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js
index 3847536ca..c8042e9de 100644
--- a/src/stores/ServicesStore.js
+++ b/src/stores/ServicesStore.js
@@ -19,8 +19,7 @@ import { DEFAULT_SERVICE_SETTINGS, KEEP_WS_LOADED_USID } from '../config';
19import { SPELLCHECKER_LOCALES } from '../i18n/languages'; 19import { SPELLCHECKER_LOCALES } from '../i18n/languages';
20import { ferdiumVersion } from '../environment-remote'; 20import { ferdiumVersion } from '../environment-remote';
21 21
22// TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed 22const debug = require('../preload-safe-debug')('Ferdium:ServiceStore');
23// const debug = require('debug')('Ferdium:ServiceStore');
24 23
25export default class ServicesStore extends Store { 24export default class ServicesStore extends Store {
26 @observable allServicesRequest = new CachedRequest(this.api.services, 'all'); 25 @observable allServicesRequest = new CachedRequest(this.api.services, 'all');
@@ -213,7 +212,7 @@ export default class ServicesStore extends Store {
213 serviceMaintenanceTick = debounce(() => { 212 serviceMaintenanceTick = debounce(() => {
214 this._serviceMaintenance(); 213 this._serviceMaintenance();
215 this.serviceMaintenanceTick(); 214 this.serviceMaintenanceTick();
216 console.log('Service maintenance tick'); 215 debug('Service maintenance tick');
217 }, ms('10s')); 216 }, ms('10s'));
218 217
219 /** 218 /**
@@ -251,7 +250,7 @@ export default class ServicesStore extends Store {
251 // If service did not reply for more than 1m try to reload. 250 // If service did not reply for more than 1m try to reload.
252 if (!service.isActive) { 251 if (!service.isActive) {
253 if (this.stores.app.isOnline && service.lostRecipeReloadAttempt < 3) { 252 if (this.stores.app.isOnline && service.lostRecipeReloadAttempt < 3) {
254 console.log( 253 debug(
255 `Reloading service: ${service.name} (${service.id}). Attempt: ${service.lostRecipeReloadAttempt}`, 254 `Reloading service: ${service.name} (${service.id}). Attempt: ${service.lostRecipeReloadAttempt}`,
256 ); 255 );
257 // service.webview.reload(); 256 // service.webview.reload();
@@ -260,7 +259,7 @@ export default class ServicesStore extends Store {
260 service.lostRecipeConnection = false; 259 service.lostRecipeConnection = false;
261 } 260 }
262 } else { 261 } else {
263 console.log(`Service lost connection: ${service.name} (${service.id}).`); 262 debug(`Service lost connection: ${service.name} (${service.id}).`);
264 service.lostRecipeConnection = true; 263 service.lostRecipeConnection = true;
265 } 264 }
266 } else { 265 } else {
@@ -364,7 +363,7 @@ export default class ServicesStore extends Store {
364 return activeService; 363 return activeService;
365 } 364 }
366 365
367 console.log('Service not available'); 366 debug('Service not available');
368 } 367 }
369 368
370 return null; 369 return null;
@@ -398,9 +397,9 @@ export default class ServicesStore extends Store {
398 skipCleanup = false, 397 skipCleanup = false,
399 }) { 398 }) {
400 if (!this.stores.recipes.isInstalled(recipeId)) { 399 if (!this.stores.recipes.isInstalled(recipeId)) {
401 console.log(`Recipe "${recipeId}" is not installed, installing recipe`); 400 debug(`Recipe "${recipeId}" is not installed, installing recipe`);
402 await this.stores.recipes._install({ recipeId }); 401 await this.stores.recipes._install({ recipeId });
403 console.log(`Recipe "${recipeId}" installed`); 402 debug(`Recipe "${recipeId}" installed`);
404 } 403 }
405 404
406 // set default values for serviceData 405 // set default values for serviceData
@@ -617,7 +616,7 @@ export default class ServicesStore extends Store {
617 if (service) { 616 if (service) {
618 service.isActive = false; 617 service.isActive = false;
619 } else { 618 } else {
620 console.log('No service is active'); 619 debug('No service is active');
621 } 620 }
622 } 621 }
623 622
@@ -660,7 +659,7 @@ export default class ServicesStore extends Store {
660 service.webview = webview; 659 service.webview = webview;
661 660
662 if (!service.isAttached) { 661 if (!service.isAttached) {
663 console.log('Webview is not attached, initializing'); 662 debug('Webview is not attached, initializing');
664 service.initializeWebViewEvents({ 663 service.initializeWebViewEvents({
665 handleIPCMessage: this.actions.service.handleIPCMessage, 664 handleIPCMessage: this.actions.service.handleIPCMessage,
666 openWindow: this.actions.service.openWindow, 665 openWindow: this.actions.service.openWindow,
@@ -709,7 +708,7 @@ export default class ServicesStore extends Store {
709 } 708 }
710 } 709 }
711 } else { 710 } else {
712 console.log('No service is active'); 711 debug('No service is active');
713 } 712 }
714 } else { 713 } else {
715 this.allServicesRequest.invalidate(); 714 this.allServicesRequest.invalidate();
@@ -728,7 +727,7 @@ export default class ServicesStore extends Store {
728 // eslint-disable-next-line default-case 727 // eslint-disable-next-line default-case
729 switch (channel) { 728 switch (channel) {
730 case 'hello': { 729 case 'hello': {
731 console.log('Received hello event from', serviceId); 730 debug('Received hello event from', serviceId);
732 731
733 this._initRecipePolling(service.id); 732 this._initRecipePolling(service.id);
734 this._initializeServiceRecipeInWebview(serviceId); 733 this._initializeServiceRecipeInWebview(serviceId);
@@ -742,7 +741,7 @@ export default class ServicesStore extends Store {
742 break; 741 break;
743 } 742 }
744 case 'message-counts': { 743 case 'message-counts': {
745 console.log(`Received unread message info from '${serviceId}'`, args[0]); 744 debug(`Received unread message info from '${serviceId}'`, args[0]);
746 745
747 this.actions.service.setUnreadMessageCount({ 746 this.actions.service.setUnreadMessageCount({
748 serviceId, 747 serviceId,
@@ -755,7 +754,7 @@ export default class ServicesStore extends Store {
755 break; 754 break;
756 } 755 }
757 case 'active-dialog-title': { 756 case 'active-dialog-title': {
758 console.log(`Received active dialog title from '${serviceId}'`, args[0]); 757 debug(`Received active dialog title from '${serviceId}'`, args[0]);
759 758
760 this.actions.service.setDialogTitle({ 759 this.actions.service.setDialogTitle({
761 serviceId, 760 serviceId,
@@ -920,7 +919,7 @@ export default class ServicesStore extends Store {
920 serviceId: service.id, 919 serviceId: service.id,
921 }); 920 });
922 } else { 921 } else {
923 console.log('No service is active'); 922 debug('No service is active');
924 } 923 }
925 } 924 }
926 925
@@ -1028,7 +1027,7 @@ export default class ServicesStore extends Store {
1028 if (service) { 1027 if (service) {
1029 this._openDevTools({ serviceId: service.id }); 1028 this._openDevTools({ serviceId: service.id });
1030 } else { 1029 } else {
1031 console.log('No service is active'); 1030 debug('No service is active');
1032 } 1031 }
1033 } 1032 }
1034 1033
@@ -1038,7 +1037,7 @@ export default class ServicesStore extends Store {
1038 return; 1037 return;
1039 } 1038 }
1040 1039
1041 console.log(`Hibernate ${service.name}`); 1040 debug(`Hibernate ${service.name}`);
1042 1041
1043 service.isHibernationRequested = true; 1042 service.isHibernationRequested = true;
1044 service.lastHibernated = Date.now(); 1043 service.lastHibernated = Date.now();
@@ -1048,7 +1047,7 @@ export default class ServicesStore extends Store {
1048 const now = Date.now(); 1047 const now = Date.now();
1049 const service = this.one(serviceId); 1048 const service = this.one(serviceId);
1050 const automaticTag = automatic ? ' automatically ' : ' '; 1049 const automaticTag = automatic ? ' automatically ' : ' ';
1051 console.log( 1050 debug(
1052 `Waking up${automaticTag}from service hibernation for ${service.name}`, 1051 `Waking up${automaticTag}from service hibernation for ${service.name}`,
1053 ); 1052 );
1054 1053
@@ -1069,8 +1068,8 @@ export default class ServicesStore extends Store {
1069 // 1068 //
1070 const mainStrategy = this.stores.settings.all.app.hibernationStrategy; 1069 const mainStrategy = this.stores.settings.all.app.hibernationStrategy;
1071 let strategy = this.stores.settings.all.app.wakeUpHibernationStrategy; 1070 let strategy = this.stores.settings.all.app.wakeUpHibernationStrategy;
1072 console.log(`wakeUpHibernationStrategy = ${strategy}`); 1071 debug(`wakeUpHibernationStrategy = ${strategy}`);
1073 console.log(`hibernationStrategy = ${mainStrategy}`); 1072 debug(`hibernationStrategy = ${mainStrategy}`);
1074 if (!strategy || strategy < 1) { 1073 if (!strategy || strategy < 1) {
1075 strategy = this.stores.settings.all.app.hibernationStrategy; 1074 strategy = this.stores.settings.all.app.hibernationStrategy;
1076 } 1075 }
@@ -1082,16 +1081,16 @@ export default class ServicesStore extends Store {
1082 ) { 1081 ) {
1083 // Add 10 additional seconds 50% of the time. 1082 // Add 10 additional seconds 50% of the time.
1084 splay = 10; 1083 splay = 10;
1085 console.log('Added splay'); 1084 debug('Added splay');
1086 } else { 1085 } else {
1087 console.log('skipping splay'); 1086 debug('skipping splay');
1088 } 1087 }
1089 // wake up again in strategy + splay seconds instead of mainStrategy seconds. 1088 // wake up again in strategy + splay seconds instead of mainStrategy seconds.
1090 service.lastUsed = now - ms(`${mainStrategy - (strategy + splay)}s`); 1089 service.lastUsed = now - ms(`${mainStrategy - (strategy + splay)}s`);
1091 } else { 1090 } else {
1092 service.lastUsed = now; 1091 service.lastUsed = now;
1093 } 1092 }
1094 console.log( 1093 debug(
1095 `Setting service.lastUsed to ${service.lastUsed} (${ 1094 `Setting service.lastUsed to ${service.lastUsed} (${
1096 (now - service.lastUsed) / 1000 1095 (now - service.lastUsed) / 1000
1097 }s ago)`, 1096 }s ago)`,
@@ -1101,7 +1100,7 @@ export default class ServicesStore extends Store {
1101 } 1100 }
1102 1101
1103 @action _resetLastPollTimer({ serviceId = null }) { 1102 @action _resetLastPollTimer({ serviceId = null }) {
1104 console.log( 1103 debug(
1105 `Reset last poll timer for ${ 1104 `Reset last poll timer for ${
1106 serviceId ? `service: "${serviceId}"` : 'all services' 1105 serviceId ? `service: "${serviceId}"` : 'all services'
1107 }`, 1106 }`,
@@ -1132,7 +1131,7 @@ export default class ServicesStore extends Store {
1132 service.dialogTitle ? ` - ${service.dialogTitle}` : '' 1131 service.dialogTitle ? ` - ${service.dialogTitle}` : ''
1133 } ${service._webview ? `- ${service._webview.getTitle()}` : ''}`; 1132 } ${service._webview ? `- ${service._webview.getTitle()}` : ''}`;
1134 } else { 1133 } else {
1135 console.log('No service is active'); 1134 debug('No service is active');
1136 } 1135 }
1137 } 1136 }
1138 1137
@@ -1146,7 +1145,7 @@ export default class ServicesStore extends Store {
1146 }, 1145 },
1147 }); 1146 });
1148 } else { 1147 } else {
1149 console.log('No service is active'); 1148 debug('No service is active');
1150 } 1149 }
1151 } 1150 }
1152 1151
@@ -1262,7 +1261,7 @@ export default class ServicesStore extends Store {
1262 this.allDisplayed.findIndex(service => service.isActive) === -1 && 1261 this.allDisplayed.findIndex(service => service.isActive) === -1 &&
1263 this.allDisplayed.length > 0 1262 this.allDisplayed.length > 0
1264 ) { 1263 ) {
1265 console.log('No active service found, setting active service to index 0'); 1264 debug('No active service found, setting active service to index 0');
1266 1265
1267 this._setActive({ serviceId: this.allDisplayed[0].id }); 1266 this._setActive({ serviceId: this.allDisplayed[0].id });
1268 } 1267 }
@@ -1278,7 +1277,7 @@ export default class ServicesStore extends Store {
1278 JSON.stringify(service.shareWithWebview), 1277 JSON.stringify(service.shareWithWebview),
1279 ); 1278 );
1280 1279
1281 console.log('Initialize recipe', service.recipe.id, service.name); 1280 debug('Initialize recipe', service.recipe.id, service.name);
1282 service.webview.send( 1281 service.webview.send(
1283 'initialize-recipe', 1282 'initialize-recipe',
1284 { 1283 {
diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js
index 3ba791239..6b6b77454 100644
--- a/src/stores/SettingsStore.js
+++ b/src/stores/SettingsStore.js
@@ -11,8 +11,7 @@ import { hash } from '../helpers/password-helpers';
11import Request from './lib/Request'; 11import Request from './lib/Request';
12import Store from './lib/Store'; 12import Store from './lib/Store';
13 13
14// TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed 14const debug = require('../preload-safe-debug')('Ferdium:SettingsStore');
15// const debug = require('debug')('Ferdium:SettingsStore');
16 15
17export default class SettingsStore extends Store { 16export default class SettingsStore extends Store {
18 @observable updateAppSettingsRequest = new Request( 17 @observable updateAppSettingsRequest = new Request(
@@ -95,7 +94,7 @@ export default class SettingsStore extends Store {
95 } 94 }
96 }); 95 });
97 } 96 }
98 console.log('Get appSettings resolves', resp.type, resp.data); 97 debug('Get appSettings resolves', resp.type, resp.data);
99 Object.assign(this._fileSystemSettingsCache[resp.type], resp.data); 98 Object.assign(this._fileSystemSettingsCache[resp.type], resp.data);
100 this.loaded = true; 99 this.loaded = true;
101 ipcRenderer.send('initialAppSettings', resp); 100 ipcRenderer.send('initialAppSettings', resp);
@@ -147,10 +146,10 @@ export default class SettingsStore extends Store {
147 @action async _update({ type, data }) { 146 @action async _update({ type, data }) {
148 const appSettings = this.all; 147 const appSettings = this.all;
149 if (!this.fileSystemSettingsTypes.includes(type)) { 148 if (!this.fileSystemSettingsTypes.includes(type)) {
150 console.log('Update settings', type, data, this.all); 149 debug('Update settings', type, data, this.all);
151 localStorage.setItem(type, Object.assign(appSettings[type], data)); 150 localStorage.setItem(type, Object.assign(appSettings[type], data));
152 } else { 151 } else {
153 console.log('Update settings on file system', type, data); 152 debug('Update settings on file system', type, data);
154 ipcRenderer.send('updateAppSettings', { 153 ipcRenderer.send('updateAppSettings', {
155 type, 154 type,
156 data, 155 data,
@@ -201,7 +200,7 @@ export default class SettingsStore extends Store {
201 }); 200 });
202 } 201 }
203 202
204 console.log('Migrated updates settings'); 203 debug('Migrated updates settings');
205 }); 204 });
206 205
207 this._ensureMigrationAndMarkDone('5.6.0-beta.6-settings', () => { 206 this._ensureMigrationAndMarkDone('5.6.0-beta.6-settings', () => {
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';
10import Request from './lib/Request'; 10import Request from './lib/Request';
11import CachedRequest from './lib/CachedRequest'; 11import 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 13const 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
17export default class UserStore extends Store { 16export 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,