aboutsummaryrefslogtreecommitdiff
path: root/src/main/updater/http.ts
diff options
context:
space:
mode:
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));