From 6d42b4fe89a7cc8b615ad8821ce6539a82427af4 Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Wed, 17 Jul 2024 10:19:28 +0200 Subject: [PATCH 1/6] extend timeout to 10 seconds, fix undefined values --- main.js | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/main.js b/main.js index 4cd0cce..c520970 100644 --- a/main.js +++ b/main.js @@ -116,7 +116,8 @@ function startOsuStatus() { const windowTitle = firstInstance.processTitle; lastOsuStatus = windowTitle; const currentStatusRequest = await fetch( - "https://api.ez-pp.farm/v1/get_player_status?name=" + currentUser.username, + "https://api.ez-pp.farm/v1/get_player_status?name=" + + currentUser.username, ); const currentStatus = await currentStatusRequest.json(); @@ -127,7 +128,8 @@ function startOsuStatus() { const currentModeString = gamemodes[currentMode]; const currentInfoRequest = await fetch( - "https://api.ez-pp.farm/v1/get_player_info?name=" + currentUser.username + "&scope=all", + "https://api.ez-pp.farm/v1/get_player_info?name=" + + currentUser.username + "&scope=all", ); const currentInfo = await currentInfoRequest.json(); let currentUsername = currentInfo.player.info.name; @@ -237,7 +239,7 @@ function registerIPCPipes() { }; } const timeout = new AbortController(); - const timeoutId = setTimeout(() => timeout.abort(), 8000); + const timeoutId = setTimeout(() => timeout.abort(), 1000 * 10); logger.log(`Logging in with user ${args.username}...`); try { const fetchResult = await fetch("https://ez-pp.farm/login/check", { @@ -268,7 +270,7 @@ function registerIPCPipes() { return result; } logger.log( - `Login failed for user ${username}.\nResponse:\n${await fetchResult + `Login failed for user ${args.username}.\nResponse:\n${await fetchResult .text()}`, ); return { @@ -384,7 +386,7 @@ function registerIPCPipes() { } if (key == "logging") { - logger.enabled = logging; + logger.enabled = value; } if (typeof value == "boolean") { @@ -432,8 +434,9 @@ function registerIPCPipes() { ipcMain.handle("ezpplauncher:checkUpdate", async (e) => { const updateInfo = await updateAvailable(); - if (updateInfo.update) + if (updateInfo.update) { mainWindow.webContents.send("ezpplauncher:update", updateInfo.release); + } }); ipcMain.handle("ezpplauncher:exitAndUpdate", async (e) => { @@ -529,8 +532,9 @@ function registerIPCPipes() { progress: Math.ceil(data.progress), }); mainWindow.webContents.send("ezpplauncher:launchstatus", { - status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${formatBytes(data.total) - })...`, + status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${ + formatBytes(data.total) + })...`, }); }); await updateDownloader.startDownload(); @@ -557,13 +561,15 @@ function registerIPCPipes() { status: "Looking for patcher updates...", }); await new Promise((res) => setTimeout(res, 1000)); - const [patchFiles, allUpdateFiles] = await getEZPPLauncherUpdateFiles(osuPath); + const [patchFiles, allUpdateFiles] = await getEZPPLauncherUpdateFiles( + osuPath, + ); if (patchFiles.length > 0) { logger.log("EZPPLauncher updates found."); const patcherDownloader = await downloadEZPPLauncherUpdateFiles( osuPath, patchFiles, - allUpdateFiles + allUpdateFiles, ); let errored = false; patcherDownloader.eventEmitter.on("error", (data) => { @@ -584,8 +590,9 @@ function registerIPCPipes() { progress: Math.ceil(data.progress), }); mainWindow.webContents.send("ezpplauncher:launchstatus", { - status: `Downloading ${data.fileName}(${formatBytes(data.loaded) - }/${formatBytes(data.total)})...`, + status: `Downloading ${data.fileName}(${ + formatBytes(data.loaded) + }/${formatBytes(data.total)})...`, }); }); patcherDownloader.eventEmitter.on("delete", (data) => { @@ -728,7 +735,8 @@ function registerIPCPipes() { const osuGameplayFile = path.join(osuPath, "osu!gameplay.dll"); if (isWritable(osuUIFile) && isWritable(osuGameplayFile)) { logger.log( - `Cleanup complete, took ${((performance.now() - timeStart) / 1000).toFixed(3) + `Cleanup complete, took ${ + ((performance.now() - timeStart) / 1000).toFixed(3) } seconds.`, ); clearInterval(cleanup); From b0f180f1fb75b814471cbc6d0412da20e035d76f Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Wed, 17 Jul 2024 10:19:51 +0200 Subject: [PATCH 2/6] fix message log on error --- src/pages/Login.svelte | 51 ++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/src/pages/Login.svelte b/src/pages/Login.svelte index 2613b63..316e13c 100644 --- a/src/pages/Login.svelte +++ b/src/pages/Login.svelte @@ -1,10 +1,14 @@