[Bootstrap] Add --start-minimized support

This commit is contained in:
Ducko 2021-12-26 17:48:09 +00:00
parent 1e428e58a2
commit e827df58c0
1 changed files with 7 additions and 3 deletions

10
src/bootstrap.js vendored
View File

@ -6,6 +6,7 @@ log('Bootstrap', 'Forcing Electron props');
app.name = 'discord'; // Force name as sometimes breaks data path even with "discord" name (also fixes kernel?) app.name = 'discord'; // Force name as sometimes breaks data path even with "discord" name (also fixes kernel?)
const requireNative = require('./utils/requireNative'); const requireNative = require('./utils/requireNative');
const argv = require('./utils/argv');
const paths = require('./paths'); const paths = require('./paths');
global.moduleDataPath = paths.getModuleDataPath(); // Global because discord global.moduleDataPath = paths.getModuleDataPath(); // Global because discord
@ -89,7 +90,10 @@ const startCore = () => {
}; };
const startUpdate = () => { const startUpdate = () => {
appUpdater.update(false, () => { const startMinimized = argv.hasFlag('--start-minimized');
log('Bootstrap', 'Start minimized:', startMinimized);
appUpdater.update(startMinimized, () => {
if (process.env.OPENASAR_NOSTART) { if (process.env.OPENASAR_NOSTART) {
log('Bootstrap', 'Found nostart variable, halting bootstrap'); log('Bootstrap', 'Found nostart variable, halting bootstrap');
return; return;
@ -98,7 +102,7 @@ const startUpdate = () => {
startCore(); startCore();
}, () => { }, () => {
log('Bootstrap', 'Setting main window visible'); log('Bootstrap', 'Setting main window visible');
desktopCore.setMainWindowVisible(true); desktopCore.setMainWindowVisible(!startMinimized);
setTimeout(() => { // Try to update our asar setTimeout(() => { // Try to update our asar
if (oaConfig.autoupdate === false) return; // If autoupdate disabled, don't update if (oaConfig.autoupdate === false) return; // If autoupdate disabled, don't update
@ -140,4 +144,4 @@ getInstallPath: ${paths.getInstallPath()}`);
} else { } else {
app.once('ready', startUpdate); app.once('ready', startUpdate);
} }
}; };