mirror of
https://gitlab.com/vyla-entertainment/home.git
synced 2026-11-20 17:15:39 -05:00
add user-prompted app updates
This commit is contained in:
25
main.js
25
main.js
@@ -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.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user