improve persistence
This commit is contained in:
parent
f5671d73cd
commit
0c004e677e
1 changed files with 16 additions and 3 deletions
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
|
||||
import { app } from "electron";
|
||||
import EventEmitter from "events";
|
||||
import { copyFileSync, existsSync, readdirSync, renameSync } from "original-fs";
|
||||
import { basename, dirname, join } from "path";
|
||||
|
||||
|
|
@ -65,6 +66,18 @@ function patchLatest() {
|
|||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
if (process.platform === "win32" || process.platform === "linux") {
|
||||
EventEmitter.prototype.emit = new Proxy(EventEmitter.prototype.emit, {
|
||||
apply(target, thisArg, argArray) {
|
||||
if (argArray[0] === "host-updated") {
|
||||
patchLatest();
|
||||
}
|
||||
|
||||
return Reflect.apply(target, thisArg, argArray);
|
||||
},
|
||||
});
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue