From 8d61a8b2b78b6fa0987a12e867f4726bef74d3a2 Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Fri, 19 Jan 2024 16:24:39 +0100 Subject: [PATCH] preperations for update dialog --- electron/updateCheck.js | 7 +++++-- main.js | 7 +++++-- package-lock.json | 10 ++++++++++ package.json | 1 + preload.js | 6 ++++++ src/App.svelte | 31 ++++++++++++++++++++++++++----- src/app.pcss | 7 +++++++ 7 files changed, 60 insertions(+), 9 deletions(-) diff --git a/electron/updateCheck.js b/electron/updateCheck.js index c033f60..df0e1aa 100644 --- a/electron/updateCheck.js +++ b/electron/updateCheck.js @@ -10,9 +10,12 @@ module.exports = { const latestRelease = await fetch(repoUrl); const json = await latestRelease.json(); if (json.length <= 0) return false; - return semver.lt(appVersion, json[0].tag_name); + return { + update: semver.lt(appVersion, json[0].tag_name), + release: json[0], + }; } catch (err) { - return false; + return { update: false }; } }, }; diff --git a/main.js b/main.js index 4743e9e..23fe689 100644 --- a/main.js +++ b/main.js @@ -572,9 +572,12 @@ function createWindow() { // Emitted when the window is ready to be shown // This helps in showing the window gracefully. mainWindow.once("ready-to-show", async () => { - const hasUpdate = await updateAvailable(); - console.log({ hasUpdate }); + const updateInfo = await updateAvailable(); + if (!updateInfo.update) { + mainWindow.webContents.send("ezpplauncher:update", updateInfo.release); + } mainWindow.show(); + mainWindow.focus(); }); } diff --git a/package-lock.json b/package-lock.json index e8e3b38..27d5d85 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "regedit-rs": "^1.0.2", "semver": "^7.5.4", "svelte-french-toast": "^1.2.0", + "sweetalert2": "^11.10.3", "systeminformation": "^5.21.22" }, "devDependencies": { @@ -8484,6 +8485,15 @@ "integrity": "sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow==", "dev": true }, + "node_modules/sweetalert2": { + "version": "11.10.3", + "resolved": "https://registry.npmjs.org/sweetalert2/-/sweetalert2-11.10.3.tgz", + "integrity": "sha512-mZYtQR7v+khyEruq0SsVUa6XIdI9Aue8s2XAIpAwdlLN1T0w7mxKEjyubiBZ3/bLbHC/wGS4wNABvXWubCizvA==", + "funding": { + "type": "individual", + "url": "https://github.com/sponsors/limonte" + } + }, "node_modules/systeminformation": { "version": "5.21.22", "resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-5.21.22.tgz", diff --git a/package.json b/package.json index 9766c6c..8809313 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "regedit-rs": "^1.0.2", "semver": "^7.5.4", "svelte-french-toast": "^1.2.0", + "sweetalert2": "^11.10.3", "systeminformation": "^5.21.22" }, "devDependencies": { diff --git a/preload.js b/preload.js index 4bf8c20..ab23735 100644 --- a/preload.js +++ b/preload.js @@ -105,3 +105,9 @@ ipcRenderer.addListener("ezpplauncher:launchprogress", (e, args) => { new CustomEvent("launchProgressUpdate", { detail: args }), ); }); + +ipcRenderer.addListener("ezpplauncher:update", (e, args) => { + window.dispatchEvent( + new CustomEvent("update", { detail: args }), + ); +}); diff --git a/src/App.svelte b/src/App.svelte index 7970f4b..580edd0 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -6,11 +6,14 @@ DropdownHeader, DropdownDivider, Button, + Modal, + Indicator, } from "flowbite-svelte"; import { ArrowLeftSolid, ArrowRightFromBracketSolid, ArrowRightToBracketSolid, + HeartSolid, UserSettingsSolid, } from "flowbite-svelte-icons"; import ezppLogo from "../public/favicon.png"; @@ -33,14 +36,14 @@ let user: User | undefined = undefined; let loggedIn = false; + let showUpdateDialog = false; + let updateInfo: Record; + currentUser.subscribe((newUser) => { loggedIn = newUser != undefined; user = newUser; }); - presence.subscribe((val) => { - }); - const logout = () => { window.dispatchEvent(new CustomEvent("logout")); currentUser.set(undefined); @@ -53,14 +56,22 @@ }); }; + window.addEventListener("update", (e) => { + const update = (e as CustomEvent).detail; + setTimeout(() => { + showUpdateDialog = true; + updateInfo = update; + + document.getElementById("updateDialog")?.blur(); + }, 2000); + }); + window.addEventListener("launchStatusUpdate", (e) => { - console.log((e as CustomEvent).detail); const status = (e as CustomEvent).detail.status; launchStatus.set(status); }); window.addEventListener("launchProgressUpdate", (e) => { - console.log((e as CustomEvent).detail); const progress = (e as CustomEvent).detail.progress; launchPercentage.set(progress); }); @@ -108,6 +119,8 @@ + +
{#if $currentPage == Page.Settings} @@ -137,6 +150,14 @@ : "https://a.ez-pp.farm/0"} id="avatar-menu" /> + + {#if $currentUser && $currentUser.id == 1001} + + + + + + {/if}
diff --git a/src/app.pcss b/src/app.pcss index 6ede246..5002c22 100644 --- a/src/app.pcss +++ b/src/app.pcss @@ -5,6 +5,8 @@ * { font-family: "Prompt"; + -webkit-user-select: none !important; + user-select: none !important; } html .cet-titlebar { @@ -62,6 +64,11 @@ html .cet-titlebar .cet-control-icon svg { transition: width 0.35s cubic-bezier(0.65, -0.02, 0.31, 1.01); } +.noselect { + -webkit-user-select: none !important; + user-select: none !important; +} + @keyframes progress-loading { 50% { background-position-x: -115%;