improve further

This commit is contained in:
Vendicated 2023-04-10 22:48:11 +02:00
parent 3ab3243176
commit 3fcafedc6f
No known key found for this signature in database
GPG key ID: A1DC0CFB5615D905
6 changed files with 51 additions and 8 deletions

View file

@ -1,6 +1,6 @@
{
"name": "VencordDesktop",
"version": "0.1.5",
"version": "0.1.4",
"private": true,
"description": "",
"keywords": [],

View file

@ -23,6 +23,7 @@ export const enum IpcEvents {
UPDATER_GET_DATA = "VCD_UPDATER_GET_DATA",
UPDATER_DOWNLOAD = "VCD_UPDATER_DOWNLOAD",
UPDATE_IGNORE = "VCD_UPDATE_IGNORE",
CLOSE = "VCD_CLOSE"
}

View file

@ -16,4 +16,5 @@ export interface Settings {
disableMinSize?: boolean;
tray?: boolean;
minimizeToTray?: boolean;
skippedUpdate?: string;
}

View file

@ -5,6 +5,7 @@
*/
import { app, BrowserWindow, ipcMain, shell } from "electron";
import { Settings } from "main/settings";
import { githubGet, ReleaseData } from "main/utils/vencordLoader";
import { join } from "path";
import { SplashProps } from "shared/browserWinProperties";
@ -38,6 +39,10 @@ ipcMain.handle(IpcEvents.UPDATER_DOWNLOAD, () => {
shell.openExternal(url);
});
ipcMain.handle(IpcEvents.UPDATE_IGNORE, () => {
Settings.store.skippedUpdate = updateData.latestVersion;
});
function isOutdated(oldVersion: string, newVersion: string) {
const oldParts = oldVersion.split(".");
const newParts = newVersion.split(".");
@ -67,12 +72,13 @@ export async function checkUpdates() {
const oldVersion = app.getVersion();
const newVersion = data.tag_name.replace(/^v/, "");
if (isOutdated(oldVersion, newVersion)) {
if (Settings.store.skippedUpdate !== newVersion && isOutdated(oldVersion, newVersion)) {
updateData = {
currentVersion: oldVersion,
latestVersion: newVersion,
release: data
};
openNewUpdateWindow();
}
} catch (e) {

View file

@ -16,5 +16,6 @@ contextBridge.exposeInMainWorld("Updater", {
invoke<void>(IpcEvents.UPDATER_DOWNLOAD);
invoke<void>(IpcEvents.CLOSE);
},
ignore: () => invoke<void>(IpcEvents.UPDATE_IGNORE),
close: () => invoke<void>(IpcEvents.CLOSE)
});

View file

@ -14,9 +14,9 @@
justify-content: space-between;
box-sizing: border-box;
height: 100%;
background-color: hsl(223 6.7% 20.6%);
background-color: #313338;
border-radius: 8px;
border: 1px solid hsl(220 6.5% 18%);
border: 1px solid #248046;
padding: 1em;
}
@ -37,6 +37,7 @@
border: none;
border-radius: 3px;
font-weight: bold;
transition: filter 0.2 ease-in-out;
}
button:hover,
@ -58,7 +59,7 @@
<div class="wrapper">
<section>
<h1>Update Available</h1>
<p>There's a new update for Vencord Desktop! Update now to get new fixes and features</p>
<p>There's a new update for Vencord Desktop! Update now to get new fixes and features!</p>
<p>
Current: <span id="current"></span>
<br />
@ -66,9 +67,16 @@
</p>
</section>
<section class="buttons">
<button class="green" onclick="Updater.download()">Download Update</button>
<button class="red" onclick="Updater.close()">Close</button>
<section>
<label id="disable-remind">
<input type="checkbox" />
<span>Do not remind again for </span>
</label>
<div class="buttons">
<button name="download" class="green">Download Update</button>
<button name="close" class="red">Close</button>
</div>
</section>
</div>
</body>
@ -77,4 +85,30 @@
const data = await Updater.getData();
document.getElementById("current").textContent = data.currentVersion;
document.getElementById("latest").textContent = data.latestVersion;
document.querySelector("#disable-remind > span").textContent += data.latestVersion;
function checkDisableRemind() {
const checkbox = document.querySelector("#disable-remind > input");
if (checkbox.checked) {
Updater.ignore();
}
}
const onClicks = {
download() {
checkDisableRemind();
Updater.download();
},
close() {
checkDisableRemind();
Updater.close();
}
};
for (const name in onClicks) {
document.querySelectorAll(`button[name="${name}"]`).forEach(button => {
button.addEventListener("click", onClicks[name]);
});
}
</script>