fixed updater not showing

This commit is contained in:
2026-08-22 14:25:04 -07:00
parent 66004a79e4
commit 86adb28f41
6 changed files with 44 additions and 12 deletions

View File

@@ -681,21 +681,27 @@
viewElement.classList.add('active');
}
if (window.__TAURI__ && window.__TAURI__.event) {
window.__TAURI__.event.listen('update-available', (e) => {
function setupTauriListeners() {
const eventApi = window.__TAURI__?.event || window.__TAURI_INTERNALS__;
if (!eventApi || typeof eventApi.listen !== 'function') {
setTimeout(setupTauriListeners, 200);
return;
}
eventApi.listen('update-available', (e) => {
if (e.payload) {
document.getElementById('update-msg').textContent = `Version ${e.payload.latest} is available (Current: ${e.payload.current}).`;
showView(viewUpdate);
}
});
window.__TAURI__.event.listen('status', (e) => {
eventApi.listen('status', (e) => {
if (e.payload && e.payload.message) {
statusMsg.textContent = e.payload.message;
}
});
window.__TAURI__.event.listen('download-progress', (e) => {
eventApi.listen('download-progress', (e) => {
if (e.payload) {
statusMsg.textContent = `Downloading update: ${e.payload.percent}%`;
progressWrap.style.display = 'block';
@@ -703,27 +709,43 @@
}
});
window.__TAURI__.event.listen('error', (e) => {
eventApi.listen('error', (e) => {
if (e.payload && e.payload.message) {
errorMsg.textContent = e.payload.message;
showView(viewError);
}
});
window.__TAURI__.event.listen('ready', (e) => {
eventApi.listen('ready', (e) => {
if (e.payload && e.payload.url) {
window.location.href = e.payload.url;
}
});
}
setupTauriListeners();
function checkUpdateApi() {
fetch('http://127.0.0.1:4891/update/info')
.then(r => r.json())
.then(data => {
if (data && data.available) {
document.getElementById('update-msg').textContent = `Version ${data.latest} is available (Current: ${data.current}).`;
showView(viewUpdate);
}
})
.catch(() => { });
}
const updateInterval = setInterval(checkUpdateApi, 500);
function installUpdate() {
clearInterval(updateInterval);
fetch('http://127.0.0.1:4891/update/yes', { method: 'POST' }).catch(() => { });
statusMsg.textContent = 'Starting update...';
showView(viewLoader);
}
function skipUpdate() {
clearInterval(updateInterval);
fetch('http://127.0.0.1:4891/update/no', { method: 'POST' }).catch(() => { });
statusMsg.textContent = 'Continuing to app...';
showView(viewLoader);