From 759d93dc198a3cc8c5265245c0144efa5435682b Mon Sep 17 00:00:00 2001 From: Vijay Aravamudhan Date: Fri, 22 Apr 2022 15:04:21 -0500 Subject: Turn off usage of 'debug' npm package using with electron-16 (fixes #17) --- src/stores/ServicesStore.js | 55 +++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 27 deletions(-) (limited to 'src/stores/ServicesStore.js') diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 1c800df59..3847536ca 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js @@ -19,7 +19,8 @@ import { DEFAULT_SERVICE_SETTINGS, KEEP_WS_LOADED_USID } from '../config'; import { SPELLCHECKER_LOCALES } from '../i18n/languages'; import { ferdiumVersion } from '../environment-remote'; -const debug = require('debug')('Ferdium:ServiceStore'); +// TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed +// const debug = require('debug')('Ferdium:ServiceStore'); export default class ServicesStore extends Store { @observable allServicesRequest = new CachedRequest(this.api.services, 'all'); @@ -212,7 +213,7 @@ export default class ServicesStore extends Store { serviceMaintenanceTick = debounce(() => { this._serviceMaintenance(); this.serviceMaintenanceTick(); - debug('Service maintenance tick'); + console.log('Service maintenance tick'); }, ms('10s')); /** @@ -250,7 +251,7 @@ export default class ServicesStore extends Store { // If service did not reply for more than 1m try to reload. if (!service.isActive) { if (this.stores.app.isOnline && service.lostRecipeReloadAttempt < 3) { - debug( + console.log( `Reloading service: ${service.name} (${service.id}). Attempt: ${service.lostRecipeReloadAttempt}`, ); // service.webview.reload(); @@ -259,7 +260,7 @@ export default class ServicesStore extends Store { service.lostRecipeConnection = false; } } else { - debug(`Service lost connection: ${service.name} (${service.id}).`); + console.log(`Service lost connection: ${service.name} (${service.id}).`); service.lostRecipeConnection = true; } } else { @@ -363,7 +364,7 @@ export default class ServicesStore extends Store { return activeService; } - debug('Service not available'); + console.log('Service not available'); } return null; @@ -397,9 +398,9 @@ export default class ServicesStore extends Store { skipCleanup = false, }) { if (!this.stores.recipes.isInstalled(recipeId)) { - debug(`Recipe "${recipeId}" is not installed, installing recipe`); + console.log(`Recipe "${recipeId}" is not installed, installing recipe`); await this.stores.recipes._install({ recipeId }); - debug(`Recipe "${recipeId}" installed`); + console.log(`Recipe "${recipeId}" installed`); } // set default values for serviceData @@ -616,7 +617,7 @@ export default class ServicesStore extends Store { if (service) { service.isActive = false; } else { - debug('No service is active'); + console.log('No service is active'); } } @@ -659,7 +660,7 @@ export default class ServicesStore extends Store { service.webview = webview; if (!service.isAttached) { - debug('Webview is not attached, initializing'); + console.log('Webview is not attached, initializing'); service.initializeWebViewEvents({ handleIPCMessage: this.actions.service.handleIPCMessage, openWindow: this.actions.service.openWindow, @@ -708,7 +709,7 @@ export default class ServicesStore extends Store { } } } else { - debug('No service is active'); + console.log('No service is active'); } } else { this.allServicesRequest.invalidate(); @@ -727,7 +728,7 @@ export default class ServicesStore extends Store { // eslint-disable-next-line default-case switch (channel) { case 'hello': { - debug('Received hello event from', serviceId); + console.log('Received hello event from', serviceId); this._initRecipePolling(service.id); this._initializeServiceRecipeInWebview(serviceId); @@ -741,7 +742,7 @@ export default class ServicesStore extends Store { break; } case 'message-counts': { - debug(`Received unread message info from '${serviceId}'`, args[0]); + console.log(`Received unread message info from '${serviceId}'`, args[0]); this.actions.service.setUnreadMessageCount({ serviceId, @@ -754,7 +755,7 @@ export default class ServicesStore extends Store { break; } case 'active-dialog-title': { - debug(`Received active dialog title from '${serviceId}'`, args[0]); + console.log(`Received active dialog title from '${serviceId}'`, args[0]); this.actions.service.setDialogTitle({ serviceId, @@ -919,7 +920,7 @@ export default class ServicesStore extends Store { serviceId: service.id, }); } else { - debug('No service is active'); + console.log('No service is active'); } } @@ -1027,7 +1028,7 @@ export default class ServicesStore extends Store { if (service) { this._openDevTools({ serviceId: service.id }); } else { - debug('No service is active'); + console.log('No service is active'); } } @@ -1037,7 +1038,7 @@ export default class ServicesStore extends Store { return; } - debug(`Hibernate ${service.name}`); + console.log(`Hibernate ${service.name}`); service.isHibernationRequested = true; service.lastHibernated = Date.now(); @@ -1047,7 +1048,7 @@ export default class ServicesStore extends Store { const now = Date.now(); const service = this.one(serviceId); const automaticTag = automatic ? ' automatically ' : ' '; - debug( + console.log( `Waking up${automaticTag}from service hibernation for ${service.name}`, ); @@ -1068,8 +1069,8 @@ export default class ServicesStore extends Store { // const mainStrategy = this.stores.settings.all.app.hibernationStrategy; let strategy = this.stores.settings.all.app.wakeUpHibernationStrategy; - debug(`wakeUpHibernationStrategy = ${strategy}`); - debug(`hibernationStrategy = ${mainStrategy}`); + console.log(`wakeUpHibernationStrategy = ${strategy}`); + console.log(`hibernationStrategy = ${mainStrategy}`); if (!strategy || strategy < 1) { strategy = this.stores.settings.all.app.hibernationStrategy; } @@ -1081,16 +1082,16 @@ export default class ServicesStore extends Store { ) { // Add 10 additional seconds 50% of the time. splay = 10; - debug('Added splay'); + console.log('Added splay'); } else { - debug('skipping splay'); + console.log('skipping splay'); } // wake up again in strategy + splay seconds instead of mainStrategy seconds. service.lastUsed = now - ms(`${mainStrategy - (strategy + splay)}s`); } else { service.lastUsed = now; } - debug( + console.log( `Setting service.lastUsed to ${service.lastUsed} (${ (now - service.lastUsed) / 1000 }s ago)`, @@ -1100,7 +1101,7 @@ export default class ServicesStore extends Store { } @action _resetLastPollTimer({ serviceId = null }) { - debug( + console.log( `Reset last poll timer for ${ serviceId ? `service: "${serviceId}"` : 'all services' }`, @@ -1131,7 +1132,7 @@ export default class ServicesStore extends Store { service.dialogTitle ? ` - ${service.dialogTitle}` : '' } ${service._webview ? `- ${service._webview.getTitle()}` : ''}`; } else { - debug('No service is active'); + console.log('No service is active'); } } @@ -1145,7 +1146,7 @@ export default class ServicesStore extends Store { }, }); } else { - debug('No service is active'); + console.log('No service is active'); } } @@ -1261,7 +1262,7 @@ export default class ServicesStore extends Store { this.allDisplayed.findIndex(service => service.isActive) === -1 && this.allDisplayed.length > 0 ) { - debug('No active service found, setting active service to index 0'); + console.log('No active service found, setting active service to index 0'); this._setActive({ serviceId: this.allDisplayed[0].id }); } @@ -1277,7 +1278,7 @@ export default class ServicesStore extends Store { JSON.stringify(service.shareWithWebview), ); - debug('Initialize recipe', service.recipe.id, service.name); + console.log('Initialize recipe', service.recipe.id, service.name); service.webview.send( 'initialize-recipe', { -- cgit v1.2.3-70-g09d2