From 6492908a62cbb8e56be6b28e574a3e9e33cc5051 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 5 Apr 2023 04:34:39 +0200 Subject: [PATCH] VencordDesktop: Fix Updater --- src/main/updater/common.ts | 2 +- src/utils/updater.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/updater/common.ts b/src/main/updater/common.ts index 3729c6d..bc628f0 100644 --- a/src/main/updater/common.ts +++ b/src/main/updater/common.ts @@ -24,7 +24,7 @@ export async function calculateHashes() { const hashes = {} as Record; await Promise.all( - ["patcher.js", "preload.js", "renderer.js", "renderer.css"].map(file => new Promise(r => { + [IS_DISCORD_DESKTOP ? "patcher.js" : "main.js", "preload.js", "renderer.js", "renderer.css"].map(file => new Promise(r => { const fis = createReadStream(join(__dirname, file)); const hash = createHash("sha1", { encoding: "hex" }); fis.once("end", () => { diff --git a/src/utils/updater.ts b/src/utils/updater.ts index d0b1fdc..3606e5f 100644 --- a/src/utils/updater.ts +++ b/src/utils/updater.ts @@ -62,7 +62,7 @@ export function getRepo() { return Unwrap(VencordNative.ipc.invoke>(IpcEvents.GET_REPO)); } -type Hashes = Record<"patcher.js" | "preload.js" | "renderer.js" | "renderer.css", string>; +type Hashes = Record<"patcher.js" | "main.js" | "preload.js" | "renderer.js" | "renderer.css", string>; /** * @returns true if hard restart is required @@ -75,8 +75,11 @@ export async function rebuild() { const newHashes = await Unwrap(VencordNative.ipc.invoke>(IpcEvents.GET_HASHES)); - return oldHashes["patcher.js"] !== newHashes["patcher.js"] || - oldHashes["preload.js"] !== newHashes["preload.js"]; + if (oldHashes["preload.js"] !== newHashes["preload.js"]) return true; + if (IS_DISCORD_DESKTOP && oldHashes["patcher.js"] !== newHashes["patcher.js"]) return true; + if (IS_VENCORD_DESKTOP && oldHashes["main.js"] !== newHashes["main.js"]) return true; + + return false; } export async function maybePromptToUpdate(confirmMessage: string, checkForDev = false) {