[General] Make log global, remove unused generic stub
This commit is contained in:
parent
b4bcd82054
commit
bcc5a2837d
8 changed files with 18 additions and 19 deletions
1
src/bootstrap.js
vendored
1
src/bootstrap.js
vendored
|
@ -2,7 +2,6 @@ const { join } = require('path');
|
||||||
const NodeModule = require('module');
|
const NodeModule = require('module');
|
||||||
const { app } = require('electron');
|
const { app } = require('electron');
|
||||||
|
|
||||||
const log = require('./utils/log');
|
|
||||||
const requireNative = require('./utils/requireNative');
|
const requireNative = require('./utils/requireNative');
|
||||||
const paths = require('./paths');
|
const paths = require('./paths');
|
||||||
const buildInfo = require('./utils/buildInfo');
|
const buildInfo = require('./utils/buildInfo');
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
const { app } = require("electron");
|
const { app } = require("electron");
|
||||||
|
|
||||||
const log = require('./utils/log');
|
|
||||||
|
|
||||||
exports.init = () => {
|
exports.init = () => {
|
||||||
/* process.on('uncaughtException', error => {
|
/* process.on('uncaughtException', error => {
|
||||||
const stack = error.stack ? error.stack : String(error);
|
const stack = error.stack ? error.stack : String(error);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const log = require('./utils/log');
|
const log = require('./utils/log');
|
||||||
|
global.log = log; // Make log global for easy usage everywhere
|
||||||
|
|
||||||
log('', 'Initing...');
|
log('', 'Initing...');
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
const { join, dirname, basename } = require('path');
|
const { join, dirname, basename } = require('path');
|
||||||
const { app } = require('electron');
|
const { app } = require('electron');
|
||||||
|
|
||||||
const log = require('./utils/log');
|
|
||||||
const buildInfo = require('./utils/buildInfo');
|
const buildInfo = require('./utils/buildInfo');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,8 @@ const events = new _events.EventEmitter();
|
||||||
exports.events = events;
|
exports.events = events;
|
||||||
|
|
||||||
function webContentsSend(win, event, ...args) {
|
function webContentsSend(win, event, ...args) {
|
||||||
|
log('Splash', `Sending to webcontents:`, event, args);
|
||||||
|
|
||||||
if (win != null && win.webContents != null) {
|
if (win != null && win.webContents != null) {
|
||||||
win.webContents.send(`DISCORD_${event}`, ...args);
|
win.webContents.send(`DISCORD_${event}`, ...args);
|
||||||
}
|
}
|
||||||
|
@ -299,6 +301,8 @@ function initOldUpdater() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function initSplash(startMinimized = false) {
|
function initSplash(startMinimized = false) {
|
||||||
|
log('Splash', `Initing splash`);
|
||||||
|
|
||||||
splashState = {};
|
splashState = {};
|
||||||
launchedMainWindow = false;
|
launchedMainWindow = false;
|
||||||
updateAttempt = 0;
|
updateAttempt = 0;
|
||||||
|
@ -315,6 +319,8 @@ function initSplash(startMinimized = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function destroySplash() {
|
function destroySplash() {
|
||||||
|
log('Splash', `Destroying splash`);
|
||||||
|
|
||||||
stopUpdateTimeout();
|
stopUpdateTimeout();
|
||||||
|
|
||||||
if (splashWindow) {
|
if (splashWindow) {
|
||||||
|
@ -385,6 +391,7 @@ function launchSplashWindow(startMinimized) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
splashWindow = new _electron.BrowserWindow(windowConfig); // prevent users from dropping links to navigate in splash window
|
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('will-navigate', e => e.preventDefault());
|
||||||
splashWindow.webContents.on('new-window', (e, windowURL) => {
|
splashWindow.webContents.on('new-window', (e, windowURL) => {
|
||||||
|
@ -408,6 +415,8 @@ function launchSplashWindow(startMinimized) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_ipcMain.default.on('SPLASH_SCREEN_READY', () => {
|
_ipcMain.default.on('SPLASH_SCREEN_READY', () => {
|
||||||
|
log('Splash', 'Window declared ready, showing and starting update process');
|
||||||
|
|
||||||
const cachedQuote = chooseCachedQuote();
|
const cachedQuote = chooseCachedQuote();
|
||||||
|
|
||||||
if (cachedQuote) {
|
if (cachedQuote) {
|
||||||
|
@ -436,6 +445,8 @@ function launchSplashWindow(startMinimized) {
|
||||||
});
|
});
|
||||||
|
|
||||||
splashWindow.loadURL(splashUrl);
|
splashWindow.loadURL(splashUrl);
|
||||||
|
|
||||||
|
log('Splash', `Loading window (with url ${splashUrl})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function launchMainWindow() {
|
function launchMainWindow() {
|
||||||
|
@ -456,12 +467,16 @@ function scheduleUpdateCheck() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function focusWindow() {
|
function focusWindow() {
|
||||||
|
log('Splash', `Told to focus splash window`);
|
||||||
|
|
||||||
if (splashWindow != null) {
|
if (splashWindow != null) {
|
||||||
splashWindow.focus();
|
splashWindow.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pageReady() {
|
function pageReady() {
|
||||||
|
log('Splash', `Page ready called, destroying splash and marking app to show`);
|
||||||
|
|
||||||
destroySplash();
|
destroySplash();
|
||||||
process.nextTick(() => events.emit(APP_SHOULD_SHOW));
|
process.nextTick(() => events.emit(APP_SHOULD_SHOW));
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,6 +155,8 @@ async function electronRequest({
|
||||||
}
|
}
|
||||||
|
|
||||||
async function requestWithMethod(method, options) {
|
async function requestWithMethod(method, options) {
|
||||||
|
log('Request', method, options);
|
||||||
|
|
||||||
if (typeof options === 'string') {
|
if (typeof options === 'string') {
|
||||||
options = {
|
options = {
|
||||||
url: options
|
url: options
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
const { readFileSync, statSync, writeFileSync } = require('fs');
|
const { readFileSync, statSync, writeFileSync } = require('fs');
|
||||||
const { join } = require('path');
|
const { join } = require('path');
|
||||||
|
|
||||||
const log = require('./log');
|
|
||||||
|
|
||||||
class Settings { // Heavily based on original for compat, but simplified and tweaked
|
class Settings { // Heavily based on original for compat, but simplified and tweaked
|
||||||
constructor(root) {
|
constructor(root) {
|
||||||
this.path = join(root, 'settings.json');
|
this.path = join(root, 'settings.json');
|
||||||
|
|
|
@ -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}`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
Loading…
Reference in a new issue