aboutsummaryrefslogtreecommitdiff
path: root/src/main/updater/http.ts
diff options
context:
space:
mode:
authorV <vendicated@riseup.net>2023-04-09 04:04:02 +0200
committerGitHub <noreply@github.com>2023-04-09 04:04:02 +0200
commit08822dd19064ea5b707117c5ed51f62dd0a8e316 (patch)
tree1020c2dad28f5dc502f797ca09066145fcc12109 /src/main/updater/http.ts
parentbfa20f2634a0f3f73a03135f9ddb9d0dfe566e88 (diff)
downloadVencord-08822dd19064ea5b707117c5ed51f62dd0a8e316.tar.gz
Vencord-08822dd19064ea5b707117c5ed51f62dd0a8e316.tar.bz2
Vencord-08822dd19064ea5b707117c5ed51f62dd0a8e316.zip
Improvements for VencordDesktop (#847)
Diffstat (limited to 'src/main/updater/http.ts')
-rw-r--r--src/main/updater/http.ts20
1 files changed, 3 insertions, 17 deletions
diff --git a/src/main/updater/http.ts b/src/main/updater/http.ts
index a2e2aad..e2a3520 100644
--- a/src/main/updater/http.ts
+++ b/src/main/updater/http.ts
@@ -26,7 +26,7 @@ import gitHash from "~git-hash";
import gitRemote from "~git-remote";
import { get } from "../utils/simpleGet";
-import { calculateHashes, serializeErrors } from "./common";
+import { serializeErrors, VENCORD_FILES } from "./common";
const API_BASE = `https://api.github.com/repos/${gitRemote}`;
let PendingUpdates = [] as [string, string][];
@@ -57,13 +57,6 @@ async function calculateGitChanges() {
}));
}
-const FILES_TO_DOWNLOAD = [
- IS_DISCORD_DESKTOP ? "patcher.js" : "vencordDesktopMain.js",
- "preload.js",
- IS_DISCORD_DESKTOP ? "renderer.js" : "vencordDesktopRenderer.js",
- "renderer.css"
-];
-
async function fetchUpdates() {
const release = await githubGet("/releases/latest");
@@ -73,7 +66,7 @@ async function fetchUpdates() {
return false;
data.assets.forEach(({ name, browser_download_url }) => {
- if (FILES_TO_DOWNLOAD.some(s => name.startsWith(s))) {
+ if (VENCORD_FILES.some(s => name.startsWith(s))) {
PendingUpdates.push([name, browser_download_url]);
}
});
@@ -83,13 +76,7 @@ async function fetchUpdates() {
async function applyUpdates() {
await Promise.all(PendingUpdates.map(
async ([name, data]) => writeFile(
- join(
- __dirname,
- IS_VENCORD_DESKTOP
- // vencordDesktopRenderer.js -> renderer.js
- ? name.replace(/vencordDesktop(\w)/, (_, c) => c.toLowerCase())
- : name
- ),
+ join(__dirname, name),
await get(data)
)
));
@@ -97,7 +84,6 @@ async function applyUpdates() {
return true;
}
-ipcMain.handle(IpcEvents.GET_HASHES, serializeErrors(calculateHashes));
ipcMain.handle(IpcEvents.GET_REPO, serializeErrors(() => `https://github.com/${gitRemote}`));
ipcMain.handle(IpcEvents.GET_UPDATES, serializeErrors(calculateGitChanges));
ipcMain.handle(IpcEvents.UPDATE, serializeErrors(fetchUpdates));