mirror of
https://gitlab.com/vyla-entertainment/home.git
synced 2026-11-19 16:47:21 -05:00
fixed version outdated UI
This commit is contained in:
@@ -684,26 +684,30 @@
|
||||
function setupTauriListeners() {
|
||||
const eventApi = window.__TAURI__?.event || window.__TAURI_INTERNALS__;
|
||||
if (!eventApi || typeof eventApi.listen !== 'function') {
|
||||
setTimeout(setupTauriListeners, 200);
|
||||
setTimeout(setupTauriListeners, 100);
|
||||
return;
|
||||
}
|
||||
|
||||
eventApi.listen('update-available', (e) => {
|
||||
if (e.payload) {
|
||||
document.getElementById('update-msg').textContent = `Version ${e.payload.latest} is available (Current: ${e.payload.current}).`;
|
||||
const data = e.payload || e;
|
||||
if (data) {
|
||||
isUpdating = true;
|
||||
document.getElementById('update-msg').textContent = `Version ${data.latest} is available (Current: ${data.current}).`;
|
||||
showView(viewUpdate);
|
||||
}
|
||||
});
|
||||
|
||||
eventApi.listen('status', (e) => {
|
||||
if (e.payload && e.payload.message) {
|
||||
statusMsg.textContent = e.payload.message;
|
||||
const data = e.payload || e;
|
||||
if (data && data.message && !isUpdating) {
|
||||
statusMsg.textContent = data.message;
|
||||
}
|
||||
});
|
||||
|
||||
eventApi.listen('download-progress', (e) => {
|
||||
if (e.payload) {
|
||||
statusMsg.textContent = `Downloading update: ${e.payload.percent}%`;
|
||||
const data = e.payload || e;
|
||||
if (data) {
|
||||
statusMsg.textContent = `Downloading update: ${data.percent}%`;
|
||||
progressWrap.style.display = 'block';
|
||||
progressFill.style.width = `${e.payload.percent}%`;
|
||||
}
|
||||
@@ -724,18 +728,22 @@
|
||||
}
|
||||
setupTauriListeners();
|
||||
|
||||
let isUpdating = false;
|
||||
|
||||
function checkUpdateApi() {
|
||||
if (isUpdating) return;
|
||||
fetch('http://127.0.0.1:4891/update/info')
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if (data && data.available) {
|
||||
isUpdating = true;
|
||||
document.getElementById('update-msg').textContent = `Version ${data.latest} is available (Current: ${data.current}).`;
|
||||
showView(viewUpdate);
|
||||
}
|
||||
})
|
||||
.catch(() => { });
|
||||
}
|
||||
const updateInterval = setInterval(checkUpdateApi, 500);
|
||||
const updateInterval = setInterval(checkUpdateApi, 300);
|
||||
|
||||
function installUpdate() {
|
||||
clearInterval(updateInterval);
|
||||
@@ -749,13 +757,18 @@
|
||||
fetch('http://127.0.0.1:4891/update/no', { method: 'POST' }).catch(() => { });
|
||||
statusMsg.textContent = 'Continuing to app...';
|
||||
showView(viewLoader);
|
||||
setTimeout(pollBackend, 1000);
|
||||
}
|
||||
|
||||
function pollBackend() {
|
||||
if (isUpdating || viewUpdate.classList.contains('active')) return;
|
||||
fetch('http://localhost:4890')
|
||||
.then(res => {
|
||||
if (res.ok) window.location.href = 'http://localhost:4890';
|
||||
else setTimeout(pollBackend, 1000);
|
||||
if (res.ok && !viewUpdate.classList.contains('active')) {
|
||||
window.location.href = 'http://localhost:4890';
|
||||
} else {
|
||||
setTimeout(pollBackend, 1000);
|
||||
}
|
||||
})
|
||||
.catch(() => setTimeout(pollBackend, 1000));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user