[Splash > Backend] Minor source cleanup
This commit is contained in:
parent
388736c56c
commit
1ab07b45c1
1 changed files with 10 additions and 11 deletions
|
@ -10,7 +10,7 @@ let splashState = {};
|
||||||
let modulesListeners = {};
|
let modulesListeners = {};
|
||||||
let launchedMainWindow = false;
|
let launchedMainWindow = false;
|
||||||
let updateAttempt = 0;
|
let updateAttempt = 0;
|
||||||
let splashWindow, newUpdater;
|
let win, newUpdater;
|
||||||
|
|
||||||
|
|
||||||
exports.initSplash = (startMin = false) => {
|
exports.initSplash = (startMin = false) => {
|
||||||
|
@ -37,25 +37,25 @@ exports.initSplash = (startMin = false) => {
|
||||||
}, 300);
|
}, 300);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.focusWindow = () => splashWindow?.focus?.();
|
exports.focusWindow = () => win?.focus?.();
|
||||||
exports.pageReady = () => destroySplash() || process.nextTick(() => events.emit('APP_SHOULD_SHOW'));
|
exports.pageReady = () => destroySplash() || process.nextTick(() => events.emit('APP_SHOULD_SHOW'));
|
||||||
|
|
||||||
const destroySplash = () => {
|
const destroySplash = () => {
|
||||||
splashWindow?.setSkipTaskbar?.(true);
|
win?.setSkipTaskbar?.(true);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!splashWindow) return;
|
if (!win) return;
|
||||||
|
|
||||||
splashWindow.hide();
|
win.hide();
|
||||||
splashWindow.close();
|
win.close();
|
||||||
splashWindow = null;
|
win = null;
|
||||||
}, 100);
|
}, 100);
|
||||||
};
|
};
|
||||||
|
|
||||||
const launchMain = () => {
|
const launchMain = () => {
|
||||||
for (const e in modulesListeners) moduleUpdater.events.removeListener(e, modulesListeners[e]); // Remove updater v1 listeners
|
for (const e in modulesListeners) moduleUpdater.events.removeListener(e, modulesListeners[e]); // Remove updater v1 listeners
|
||||||
|
|
||||||
if (!launchedMainWindow && splashWindow != null) {
|
if (!launchedMainWindow && win != null) {
|
||||||
sendState('starting');
|
sendState('starting');
|
||||||
|
|
||||||
launchedMainWindow = true;
|
launchedMainWindow = true;
|
||||||
|
@ -65,13 +65,13 @@ const launchMain = () => {
|
||||||
|
|
||||||
const sendState = (status) => {
|
const sendState = (status) => {
|
||||||
try {
|
try {
|
||||||
splashWindow.webContents.send('state', { status, ...splashState });
|
win.webContents.send('state', { status, ...splashState });
|
||||||
} catch (_e) {}
|
} catch (_e) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const launchSplash = (startMin) => {
|
const launchSplash = (startMin) => {
|
||||||
splashWindow = new BrowserWindow({
|
win = new BrowserWindow({
|
||||||
width: 300,
|
width: 300,
|
||||||
height: process.platform === 'darwin' ? 300 : 350,
|
height: process.platform === 'darwin' ? 300 : 350,
|
||||||
frame: false,
|
frame: false,
|
||||||
|
@ -84,7 +84,6 @@ const launchSplash = (startMin) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const win = splashWindow;
|
|
||||||
const wc = win.webContents;
|
const wc = win.webContents;
|
||||||
|
|
||||||
if (process.platform !== 'darwin') win.on('closed', () => !launchedMainWindow && app.quit());
|
if (process.platform !== 'darwin') win.on('closed', () => !launchedMainWindow && app.quit());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue