diff --git a/src/bootstrap.js b/src/bootstrap.js index 50c9940..e864a66 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -2,7 +2,6 @@ const { join } = require('path'); const NodeModule = require('module'); const { app } = require('electron'); -const log = require('./utils/log'); const requireNative = require('./utils/requireNative'); const paths = require('./paths'); const buildInfo = require('./utils/buildInfo'); diff --git a/src/errorHandler.js b/src/errorHandler.js index b19f545..4fcfea2 100644 --- a/src/errorHandler.js +++ b/src/errorHandler.js @@ -1,7 +1,5 @@ const { app } = require("electron"); -const log = require('./utils/log'); - exports.init = () => { /* process.on('uncaughtException', error => { const stack = error.stack ? error.stack : String(error); diff --git a/src/index.js b/src/index.js index 3505e7d..c0966bf 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,5 @@ const log = require('./utils/log'); +global.log = log; // Make log global for easy usage everywhere log('', 'Initing...'); diff --git a/src/paths.js b/src/paths.js index bdae911..b239a1f 100644 --- a/src/paths.js +++ b/src/paths.js @@ -1,7 +1,6 @@ const { join, dirname, basename } = require('path'); const { app } = require('electron'); -const log = require('./utils/log'); const buildInfo = require('./utils/buildInfo'); diff --git a/src/splash/splashScreen.js b/src/splash/splashScreen.js index b647cba..6153ebe 100644 --- a/src/splash/splashScreen.js +++ b/src/splash/splashScreen.js @@ -67,6 +67,8 @@ const events = new _events.EventEmitter(); exports.events = events; function webContentsSend(win, event, ...args) { + log('Splash', `Sending to webcontents:`, event, args); + if (win != null && win.webContents != null) { win.webContents.send(`DISCORD_${event}`, ...args); } @@ -299,6 +301,8 @@ function initOldUpdater() { } function initSplash(startMinimized = false) { + log('Splash', `Initing splash`); + splashState = {}; launchedMainWindow = false; updateAttempt = 0; @@ -315,6 +319,8 @@ function initSplash(startMinimized = false) { } function destroySplash() { + log('Splash', `Destroying splash`); + stopUpdateTimeout(); if (splashWindow) { @@ -385,6 +391,7 @@ function launchSplashWindow(startMinimized) { } }; splashWindow = new _electron.BrowserWindow(windowConfig); // prevent users from dropping links to navigate in splash window + log('Splash', 'Created BrowserWindow'); splashWindow.webContents.on('will-navigate', e => e.preventDefault()); splashWindow.webContents.on('new-window', (e, windowURL) => { @@ -408,6 +415,8 @@ function launchSplashWindow(startMinimized) { } _ipcMain.default.on('SPLASH_SCREEN_READY', () => { + log('Splash', 'Window declared ready, showing and starting update process'); + const cachedQuote = chooseCachedQuote(); if (cachedQuote) { @@ -436,6 +445,8 @@ function launchSplashWindow(startMinimized) { }); splashWindow.loadURL(splashUrl); + + log('Splash', `Loading window (with url ${splashUrl})`); } function launchMainWindow() { @@ -456,12 +467,16 @@ function scheduleUpdateCheck() { } function focusWindow() { + log('Splash', `Told to focus splash window`); + if (splashWindow != null) { splashWindow.focus(); } } function pageReady() { + log('Splash', `Page ready called, destroying splash and marking app to show`); + destroySplash(); process.nextTick(() => events.emit(APP_SHOULD_SHOW)); } diff --git a/src/updater/request.js b/src/updater/request.js index c5a7c71..265723e 100644 --- a/src/updater/request.js +++ b/src/updater/request.js @@ -155,6 +155,8 @@ async function electronRequest({ } async function requestWithMethod(method, options) { + log('Request', method, options); + if (typeof options === 'string') { options = { url: options diff --git a/src/utils/Settings.js b/src/utils/Settings.js index f66554f..4c3750d 100644 --- a/src/utils/Settings.js +++ b/src/utils/Settings.js @@ -1,8 +1,6 @@ const { readFileSync, statSync, writeFileSync } = require('fs'); const { join } = require('path'); -const log = require('./log'); - class Settings { // Heavily based on original for compat, but simplified and tweaked constructor(root) { this.path = join(root, 'settings.json'); diff --git a/src/utils/stub.js b/src/utils/stub.js deleted file mode 100644 index 24bf6a6..0000000 --- a/src/utils/stub.js +++ /dev/null @@ -1,13 +0,0 @@ -const log = require('./log'); - -module.exports = (debugName) => { - return new Proxy({}, { - get(target, prop, receiver) { - log('Stub', `${debugName}: Tried getting ${prop}`); - }, - - set(target, prop, value, receiver) { - log('Stub', `${debugName}: Tried setting ${prop}, ${value}`); - } - }); -}; \ No newline at end of file