Fix skip splash

This commit is contained in:
smartfridge 2022-12-10 20:33:35 +01:00
parent d8af912faf
commit ea20492372
2 changed files with 26 additions and 17 deletions

View file

@ -177,7 +177,6 @@
<p data-string="settings-skipSplash-desc" class="description"></p> <p data-string="settings-skipSplash-desc" class="description"></p>
</div> </div>
<br /> <br />
<button data-string="settings-pluginsFolder" data-open="Plugins" class="center"></button> <button data-string="settings-pluginsFolder" data-open="Plugins" class="center"></button>
<br /> <br />
<button data-string="settings-themesFolder" data-open="Themes" class="center"></button> <button data-string="settings-themesFolder" data-open="Themes" class="center"></button>

View file

@ -12,7 +12,9 @@ import {
setConfig, setConfig,
setLang, setLang,
setWindowState, setWindowState,
transparency transparency,
sleep,
modInstallState
} from "./utils"; } from "./utils";
import {registerIpc} from "./ipc"; import {registerIpc} from "./ipc";
import {setMenu} from "./menu"; import {setMenu} from "./menu";
@ -74,10 +76,13 @@ async function doAfterDefiningTheWindow() {
if (!gotTheLock) { if (!gotTheLock) {
app.quit(); app.quit();
} else { } else {
app.on("second-instance", (event, commandLine, workingDirectory) => { app.on("second-instance", (event, commandLine, workingDirectory, additionalData) => {
// i love stack overflow // Print out data received from the second instance.
console.log(additionalData);
// Someone tried to run a second instance, we should focus our window.
if (mainWindow) { if (mainWindow) {
mainWindow.restore(); if (mainWindow.isMinimized()) mainWindow.restore();
mainWindow.focus(); mainWindow.focus();
} }
}); });
@ -214,31 +219,36 @@ async function doAfterDefiningTheWindow() {
await setLang(Intl.DateTimeFormat().resolvedOptions().locale); await setLang(Intl.DateTimeFormat().resolvedOptions().locale);
mainWindow.setSize(390, 470); mainWindow.setSize(390, 470);
await mainWindow.loadFile(path.join(__dirname, "/content/setup.html")); await mainWindow.loadFile(path.join(__dirname, "/content/setup.html"));
} else { } else if ((await getConfig("skipSplash")) == true) {
if ((await getConfig("skipSplash")) == true) { while (modInstallState == "installing") {
switch (await getConfig("channel")) { sleep(1000);
}
mainWindow.loadURL("data:text/html,%3Ch1%3ELoading%21%3C%2Fh1%3E");
mainWindow.webContents.executeJavaScript(`
window.armcord.splashEnd();
switch (window.armcord.channel) {
case "stable": case "stable":
await mainWindow.loadURL("https://discord.com/app"); window.location.replace("https://discord.com/app");
break; break;
case "canary": case "canary":
await mainWindow.loadURL("https://canary.discord.com/app"); window.location.replace("https://canary.discord.com/app");
break; break;
case "ptb": case "ptb":
await mainWindow.loadURL("https://ptb.discord.com/app"); window.location.replace("https://ptb.discord.com/app");
break; break;
case "hummus": case "hummus":
await mainWindow.loadURL("https://hummus.sys42.net/"); window.location.replace("https://hummus.sys42.net/");
break; break;
case undefined: case undefined:
await mainWindow.loadURL("https://discord.com/app"); window.location.replace("https://discord.com/app");
break; break;
default: default:
await mainWindow.loadURL("https://discord.com/app"); window.location.replace("https://discord.com/app");
} }
`);
} else { } else {
await mainWindow.loadFile(path.join(__dirname, "/content/splash.html")); await mainWindow.loadFile(path.join(__dirname, "/content/splash.html"));
} }
}
} }
export function createCustomWindow() { export function createCustomWindow() {
mainWindow = new BrowserWindow({ mainWindow = new BrowserWindow({