mirror of
https://gitlab.com/vyla-entertainment/home.git
synced 2026-11-21 01:25:39 -05:00
add user-prompted app updates
This commit is contained in:
@@ -633,6 +633,21 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="view-update" class="view-state">
|
||||
<div class="container">
|
||||
<svg class="icon icon-loader" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
|
||||
style="color:#0a84ff; animation:none; transform:none;">
|
||||
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3" />
|
||||
</svg>
|
||||
<h1>Update Available</h1>
|
||||
<p id="update-msg">A new version is available.</p>
|
||||
<div class="buttons">
|
||||
<button class="secondary" onclick="skipUpdate()">Skip</button>
|
||||
<button class="primary" onclick="installUpdate()">Install Update</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="view-error" class="view-state">
|
||||
<div class="container">
|
||||
<svg class="icon icon-error" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
@@ -653,6 +668,7 @@
|
||||
<script>
|
||||
const viewLoader = document.getElementById('view-loader');
|
||||
const viewError = document.getElementById('view-error');
|
||||
const viewUpdate = document.getElementById('view-update');
|
||||
|
||||
const statusMsg = document.getElementById('status-msg');
|
||||
const errorMsg = document.getElementById('error-msg');
|
||||
@@ -666,6 +682,13 @@
|
||||
}
|
||||
|
||||
if (window.__TAURI__ && window.__TAURI__.event) {
|
||||
window.__TAURI__.event.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) => {
|
||||
if (e.payload && e.payload.message) {
|
||||
statusMsg.textContent = e.payload.message;
|
||||
@@ -694,6 +717,18 @@
|
||||
});
|
||||
}
|
||||
|
||||
function installUpdate() {
|
||||
fetch('http://127.0.0.1:4891/update/yes', { method: 'POST' }).catch(() => { });
|
||||
statusMsg.textContent = 'Starting update...';
|
||||
showView(viewLoader);
|
||||
}
|
||||
|
||||
function skipUpdate() {
|
||||
fetch('http://127.0.0.1:4891/update/no', { method: 'POST' }).catch(() => { });
|
||||
statusMsg.textContent = 'Continuing to app...';
|
||||
showView(viewLoader);
|
||||
}
|
||||
|
||||
function pollBackend() {
|
||||
fetch('http://localhost:4890')
|
||||
.then(res => {
|
||||
|
||||
Reference in New Issue
Block a user