mirror of
https://gitlab.com/vyla-entertainment/home.git
synced 2026-11-21 01:25:39 -05:00
fixed updater not showing
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user