[General] Electron 17 minor rewrite, large logging cleanup
This commit is contained in:
parent
97ab2297ff
commit
9fd8dc8530
5 changed files with 14 additions and 13 deletions
6
src/bootstrap.js
vendored
6
src/bootstrap.js
vendored
|
@ -29,8 +29,7 @@ if (!settings.get('enableHardwareAcceleration', true)) app.disableHardwareAccele
|
|||
|
||||
let desktopCore;
|
||||
const startCore = () => {
|
||||
desktopCore = require('discord_desktop_core');
|
||||
log('Bootstrap', 'Required core');
|
||||
desktopCore = require('./utils/requireNative')('discord_desktop_core');
|
||||
|
||||
desktopCore.startup({
|
||||
splashScreen,
|
||||
|
@ -77,7 +76,6 @@ const startUpdate = async () => {
|
|||
|
||||
startCore();
|
||||
}, () => {
|
||||
log('Bootstrap', 'Main window visible');
|
||||
desktopCore.setMainWindowVisible(!startMinimized);
|
||||
|
||||
setTimeout(() => { // Try to update our asar
|
||||
|
@ -88,7 +86,7 @@ const startUpdate = async () => {
|
|||
try {
|
||||
require('./asarUpdate')();
|
||||
} catch (e) {
|
||||
log('AsarUpdate', 'Failed', e);
|
||||
log('AsarUpdate', e);
|
||||
}
|
||||
}
|
||||
}, 3000);
|
||||
|
|
|
@ -13,8 +13,8 @@ global.oaConfig = require('./appSettings').getSettings().get('openasar', {});
|
|||
require('./cmdSwitches')();
|
||||
|
||||
if (process.argv.includes('--overlay-host')) { // If overlay
|
||||
require('./utils/u2QuickLoad'); // Manually load updater 2 module paths (all modules)
|
||||
require('discord_overlay2/standalone_host.js'); // Start overlay
|
||||
require('./utils/u2QuickLoad'); // Manually load Updater v2 module paths (all modules)
|
||||
require('./utils/requireNative')('discord_overlay2', 'standalone_host.js'); // Start overlay
|
||||
} else {
|
||||
require('./bootstrap')(); // Start bootstrap
|
||||
}
|
|
@ -15,7 +15,7 @@ let splashWindow, updateTimeout, newUpdater;
|
|||
|
||||
|
||||
exports.initSplash = (startMinimized = false) => {
|
||||
log('Splash', `Initing`);
|
||||
log('Splash', `Init`);
|
||||
|
||||
newUpdater = updater.getUpdater();
|
||||
|
||||
|
@ -32,8 +32,6 @@ exports.initSplash = (startMinimized = false) => {
|
|||
if (process.env.OPENASAR_QUICKSTART || oaConfig.quickstart) setTimeout(() => {
|
||||
destroySplash();
|
||||
|
||||
if (newUpdater != null) require('../utils/u2QuickLoad'); // Manually load desktop_core module path for faster requiring
|
||||
|
||||
launchMainWindow();
|
||||
|
||||
setTimeout(() => {
|
||||
|
@ -62,8 +60,6 @@ const destroySplash = () => {
|
|||
};
|
||||
|
||||
const launchMainWindow = () => {
|
||||
log('Splash', 'Launch main');
|
||||
|
||||
for (const e in modulesListeners) moduleUpdater.events.removeListener(e, modulesListeners[e]); // Remove updater v1 listeners
|
||||
|
||||
if (!launchedMainWindow && splashWindow != null) {
|
||||
|
@ -204,8 +200,9 @@ const updateUntilCurrent = async () => {
|
|||
return launchMainWindow();
|
||||
}
|
||||
} catch (e) {
|
||||
log('Splash', 'Update failed', e);
|
||||
log('Splash', e);
|
||||
sendState('fail');
|
||||
|
||||
await new Promise(res => scheduleNextUpdate(res));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -406,7 +406,7 @@ exports.installPendingUpdates = () => {
|
|||
installModule(m, 0, join(bootstrapPath, m)); // Intentional invalid path
|
||||
}
|
||||
} catch (e) {
|
||||
log('Modules', 'Bootstrap fail', e);
|
||||
log('Modules', e);
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
6
src/utils/requireNative.js
Normal file
6
src/utils/requireNative.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
// Custom requireNative as Electron >=17 breaks Module.globalPaths for some reason
|
||||
// For Updater v2: get direct path in globalPaths ("d")
|
||||
// For Module Updater: get root path for all modules in globalPaths
|
||||
|
||||
const g = require('module').globalPaths;
|
||||
module.exports = (n, e = '') => require(require('path').join(g.find((x) => x.includes(n)) ?? g[0], n, e));
|
Loading…
Reference in a new issue