Skip to content

Commit

Permalink
Updater Popup: Add Changelog; Make about page prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Vendicated committed Jun 25, 2023
1 parent 477ecbb commit 49fb4c6
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 71 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "VencordDesktop",
"version": "0.2.4",
"version": "0.2.5",
"private": true,
"description": "",
"keywords": [],
Expand Down
12 changes: 6 additions & 6 deletions src/main/about.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* Copyright (c) 2023 Vendicated and Vencord contributors
*/

import { app, BrowserWindow } from "electron";
import { readFileSync } from "fs";
import { BrowserWindow } from "electron";
import { join } from "path";
import { ICON_PATH, VIEW_DIR } from "shared/paths";

Expand All @@ -15,14 +14,15 @@ export function createAboutWindow() {
const about = new BrowserWindow({
center: true,
autoHideMenuBar: true,
icon: ICON_PATH
icon: ICON_PATH,
webPreferences: {
preload: join(__dirname, "updaterPreload.js")
}
});

makeLinksOpenExternally(about);

const html = readFileSync(join(VIEW_DIR, "about.html"), "utf-8").replaceAll("%VERSION%", app.getVersion());

about.loadURL("data:text/html;charset=utf-8," + html);
about.loadFile(join(VIEW_DIR, "about.html"));

return about;
}
25 changes: 16 additions & 9 deletions src/updater/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import { app, BrowserWindow, ipcMain, shell } from "electron";
import { Settings } from "main/settings";
import { makeLinksOpenExternally } from "main/utils/makeLinksOpenExternally";
import { githubGet, ReleaseData } from "main/utils/vencordLoader";
import { join } from "path";
import { SplashProps } from "shared/browserWinProperties";
import { IpcEvents } from "shared/IpcEvents";
import { VIEW_DIR } from "shared/paths";

Expand Down Expand Up @@ -79,13 +79,13 @@ export async function checkUpdates() {

const oldVersion = app.getVersion();
const newVersion = data.tag_name.replace(/^v/, "");
if (Settings.store.skippedUpdate !== newVersion && isOutdated(oldVersion, newVersion)) {
updateData = {
currentVersion: oldVersion,
latestVersion: newVersion,
release: data
};
updateData = {
currentVersion: oldVersion,
latestVersion: newVersion,
release: data
};

if (Settings.store.skippedUpdate !== newVersion && isOutdated(oldVersion, newVersion)) {
openNewUpdateWindow();
}
} catch (e) {
Expand All @@ -95,11 +95,18 @@ export async function checkUpdates() {

function openNewUpdateWindow() {
const win = new BrowserWindow({
...SplashProps,
width: 500,
autoHideMenuBar: true,
alwaysOnTop: true,
webPreferences: {
preload: join(__dirname, "updaterPreload.js")
preload: join(__dirname, "updaterPreload.js"),
nodeIntegration: false,
contextIsolation: true,
sandbox: true
}
});

makeLinksOpenExternally(win);

win.loadFile(join(VIEW_DIR, "updater.html"));
}
15 changes: 12 additions & 3 deletions static/views/about.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<head>
<link rel="stylesheet" href="./style.css" type="text/css" />

<style>
body {
padding: 2em;
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell,
"Open Sans", "Helvetica Neue", sans-serif;
}

h1 {
Expand All @@ -13,7 +13,7 @@
</head>

<body>
<h1>Vencord Desktop %VERSION%</h1>
<h1 id="title">Vencord Desktop</h1>
<p>
Vencord Desktop is a free/libre cross platform desktop app aiming to give you a snappier Discord experience with
Vencord pre-installed
Expand Down Expand Up @@ -60,3 +60,12 @@ <h2>Acknowledgements</h2>
</ul>
</section>
</body>

<script type="module">
const data = await Updater.getData();
if (data.currentVersion) {
const title = document.getElementById("title");

title.textContent += ` v${data.currentVersion}`;
}
</script>
31 changes: 2 additions & 29 deletions static/views/first-launch.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
<head>
<style>
:root {
--bg: white;
--fg: black;
--fg-secondary: #313338;
--fg-semi-trans: rgb(0 0 0 / 0.2);
--link: #006ce7;
}

@media (prefers-color-scheme: dark) {
:root {
--bg: hsl(223 6.7% 20.6%);
--fg: white;
--fg-secondary: #b5bac1;
--fg-semi-trans: rgb(255 255 255 / 0.2);
--link: #00a8fc;
}
}
<link rel="stylesheet" href="./style.css" type="text/css" />

<style>
body {
height: 100vh;

font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell,
"Open Sans", "Helvetica Neue", sans-serif;
margin: 0;
padding: 1.5em;
padding-bottom: 1em;

Expand All @@ -34,13 +15,9 @@
box-sizing: border-box;
}

body,
select {
background: var(--bg);
color: var(--fg);
}

select {
padding: 0.3em;
margin: -0.3em;
border-radius: 6px;
Expand All @@ -54,10 +31,6 @@
margin: 1em 0 2em;
}

a {
color: var(--link);
}

form {
display: grid;
gap: 1em;
Expand Down
13 changes: 3 additions & 10 deletions static/views/splash.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
<head>
<link rel="stylesheet" href="./style.css" type="text/css" />

<style>
* {
user-select: none;
}

body {
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell,
"Open Sans", "Helvetica Neue", sans-serif;
margin: 0;
padding: 0;
}

.wrapper {
box-sizing: border-box;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: hsl(223 6.7% 20.6%);
border-radius: 8px;
border: 1px solid hsl(220 6.5% 18%);
border: 1px solid var(--fg-semi-trans);
}

p {
color: rgb(219, 222, 225);
text-align: center;
}

Expand Down
30 changes: 30 additions & 0 deletions static/views/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
:root {
--bg: white;
--fg: black;
--fg-secondary: #313338;
--fg-semi-trans: rgb(0 0 0 / 0.2);
--link: #006ce7;
}

@media (prefers-color-scheme: dark) {
:root {
--bg: hsl(223 6.7% 20.6%);
--fg: white;
--fg-secondary: #b5bac1;
--fg-semi-trans: rgb(255 255 255 / 0.2);
--link: #00a8fc;
}
}

body {
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell,
"Open Sans", "Helvetica Neue", sans-serif;
margin: 0;
padding: 0;
background: var(--bg);
color: var(--fg);
}

a {
color: var(--link);
}
34 changes: 21 additions & 13 deletions static/views/updater.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
<head>
<style>
body {
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell,
"Open Sans", "Helvetica Neue", sans-serif;
margin: 0;
padding: 0;
color: rgb(219, 222, 225);
}
<link rel="stylesheet" href="./style.css" type="text/css" />

<style>
.wrapper {
display: flex;
flex-direction: column;
justify-content: space-between;
box-sizing: border-box;
height: 100%;
background-color: #313338;
border-radius: 8px;
border: 1px solid #248046;
min-height: 100%;
padding: 1em;
}

Expand All @@ -34,7 +25,7 @@
button {
cursor: pointer;
padding: 0.5em;
color: white;
color: var(--fg);
border: none;
border-radius: 3px;
font-weight: bold;
Expand Down Expand Up @@ -66,6 +57,9 @@ <h1>Update Available</h1>
<br />
Latest: <span id="latest"></span>
</p>

<h2>Changelog</h2>
<p id="changelog">Loading...</p>
</section>

<section>
Expand Down Expand Up @@ -113,3 +107,17 @@ <h1>Update Available</h1>
});
}
</script>

<script type="module">
import { micromark } from "https://esm.sh/micromark@3?bundle";
import { gfm, gfmHtml } from "https://esm.sh/micromark-extension-gfm@2?bundle";

const changelog = (await Updater.getData()).release.body;
if (changelog)
document.getElementById("changelog").innerHTML = micromark(changelog, {
extensions: [gfm()],
htmlExtensions: [gfmHtml()]
})
.replace(/h1>/g, "h3>")
.replace(/<a /g, '<a target="_blank" ');
</script>

0 comments on commit 49fb4c6

Please sign in to comment.