add user-prompted app updates

This commit is contained in:
2026-08-22 09:03:23 -07:00
parent c3f9ce4ffd
commit 5d78dafe43
3 changed files with 59 additions and 3 deletions

25
main.js
View File

@@ -123,9 +123,30 @@ async function start() {
if (release) {
const hasUpdate = release.version !== localVersion || (release.sha256 && release.sha256 !== localSha);
if (isFirstRun || hasUpdate) {
debugLog("Update required or first run. Installing remote build...");
if (isFirstRun) {
debugLog("First run. Installing remote build...");
await installBuild(release);
} else if (hasUpdate) {
debugLog("Update available. Prompting user...");
sendToTauri('update-available', { current: localVersion, latest: release.version });
const tempApp = express();
let userDecision = null;
tempApp.post('/update/yes', (req, res) => { userDecision = true; res.sendStatus(200); });
tempApp.post('/update/no', (req, res) => { userDecision = false; res.sendStatus(200); });
const tempServer = tempApp.listen(4891, '127.0.0.1');
while (userDecision === null) {
await new Promise(r => setTimeout(r, 500));
}
tempServer.close();
if (userDecision) {
debugLog("User accepted update.");
await installBuild(release);
} else {
debugLog("User skipped update.");
}
} else {
debugLog("Already on the latest version.");
}