diff options
author | CanadaHonk <19228318+CanadaHonk@users.noreply.github.com> | 2023-08-25 13:21:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-25 14:21:27 +0200 |
commit | 60458cdf1fdd4c4a1728177e2b98f9932467d3ad (patch) | |
tree | 317ca9cf941e77c6f00ad82c52d0181318e7990f | |
parent | 714d87241ceb07dfd6c08cee55347a937e97a279 (diff) | |
download | Vencord-60458cdf1fdd4c4a1728177e2b98f9932467d3ad.tar.gz Vencord-60458cdf1fdd4c4a1728177e2b98f9932467d3ad.tar.bz2 Vencord-60458cdf1fdd4c4a1728177e2b98f9932467d3ad.zip |
Win32Updater: use before-quit event instead of patching updater (#1668)
-rw-r--r-- | src/main/patchWin32Updater.ts | 37 |
1 files changed, 3 insertions, 34 deletions
diff --git a/src/main/patchWin32Updater.ts b/src/main/patchWin32Updater.ts index 6cf1a43..1be5812 100644 --- a/src/main/patchWin32Updater.ts +++ b/src/main/patchWin32Updater.ts @@ -20,18 +20,6 @@ import { app } from "electron"; import { existsSync, mkdirSync, readdirSync, renameSync, statSync, writeFileSync } from "fs"; import { basename, dirname, join } from "path"; -const { setAppUserModelId } = app; - -// Apparently requiring Discords updater too early leads into issues, -// copied this workaround from powerCord -app.setAppUserModelId = function (id: string) { - app.setAppUserModelId = setAppUserModelId; - - setAppUserModelId.call(this, id); - - patchUpdater(); -}; - function isNewer($new: string, old: string) { const newParts = $new.slice(4).split(".").map(Number); const oldParts = old.slice(4).split(".").map(Number); @@ -77,25 +65,6 @@ function patchLatest() { } } -// Windows Host Updates install to a new folder app-{HOST_VERSION}, so we -// need to reinject -function patchUpdater() { - // Array of autoStart paths to try - const autoStartPaths = [ - join(require.main!.filename, "..", "autoStart", "win32.js"), // Vanilla - join(require.main!.filename, "..", "autoStart.js") // OpenAsar - ]; - - for (const path of autoStartPaths) { - try { - const { update } = require(path); - - require.cache[path]!.exports.update = function () { - update.apply(this, arguments); - patchLatest(); - }; - } catch { - // Ignore as non-critical - } - } -} +// Try to patch latest on before-quit +// Discord's Win32 updater will call app.quit() on restart and open new version on will-quit +app.on("before-quit", patchLatest); |