mirror of
https://github.com/pvrzz/atmosphere.git
synced 2026-11-29 05:22:26 +00:00
Check for updates while open, one-click update notice, and a release script
- Rechecks every few hours while Atmosphere is open, and when it regains focus - A notice announces each new version once, with Update and restart and What's new - scripts/release.ps1 bumps the version everywhere, commits and tags, and can push
This commit is contained in:
+1
-1
@@ -277,7 +277,7 @@
|
||||
<h2 id="set-app">App</h2>
|
||||
<div class="group">
|
||||
<div class="setting"><div><strong>Updates</strong><span id="updateInfo">Atmosphere</span></div><button class="btn" id="updateBtn" type="button"><span class="label">Check for updates</span><span class="spin" aria-hidden="true"></span></button></div>
|
||||
<label class="setting"><div><strong>Check for updates automatically</strong><span>When Atmosphere opens, it asks its GitHub releases page whether there's a newer version. Every update is signed and checked before it installs.</span></div><input type="checkbox" class="switch" data-key="checkUpdates" /></label>
|
||||
<label class="setting"><div><strong>Check for updates automatically</strong><span>When Atmosphere opens, and every few hours while it's open, it asks its GitHub releases page whether there's a newer version. You choose when to install, and every update is signed and checked first.</span></div><input type="checkbox" class="switch" data-key="checkUpdates" /></label>
|
||||
<div class="setting">
|
||||
<div><strong>Appearance</strong><span>Follows Windows unless you choose.</span></div>
|
||||
<div class="seg" data-seg="theme"><button type="button" data-value="system">System</button><button type="button" data-value="light">Light</button><button type="button" data-value="dark">Dark</button></div>
|
||||
|
||||
@@ -1204,3 +1204,14 @@ body.mini-mode > *:not(#mini):not(.toasts):not(.modal-wrap):not(script) { displa
|
||||
.pick-logo { display: grid; gap: 6px; padding: var(--s3); border-radius: var(--r-ctl); border: 1px solid var(--border); background: repeating-conic-gradient(rgba(127, 127, 127, 0.14) 0 25%, transparent 0 50%) 0 0 / 14px 14px; color: var(--text-2); font-size: 12px; text-align: center; cursor: pointer; }
|
||||
.pick-logo img { width: 100%; height: 56px; object-fit: contain; }
|
||||
.pick-logo.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
|
||||
|
||||
/* update notice */
|
||||
.update-notice { position: fixed; right: var(--s5); bottom: 100px; z-index: 95; width: min(380px, calc(100vw - 32px)); display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s2) var(--s3); align-items: start; padding: var(--s4); border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); animation: menuIn 200ms var(--ease); }
|
||||
.update-notice.out { opacity: 0; transform: translateY(6px); transition: opacity 180ms var(--ease), transform 180ms var(--ease); }
|
||||
.un-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
|
||||
.un-text { display: grid; gap: 2px; min-width: 0; }
|
||||
.un-text strong { font-size: 13.5px; }
|
||||
.un-text span { color: var(--text-2); font-size: 12.5px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
|
||||
.un-actions { grid-column: 2 / 4; display: flex; gap: var(--s2); flex-wrap: wrap; }
|
||||
.un-close { grid-column: 3; grid-row: 1; margin: -6px -6px 0 0; }
|
||||
@media (prefers-reduced-motion: reduce) { .update-notice { animation: none; } .update-notice.out { transition: none; } }
|
||||
|
||||
+31
-2
@@ -1,5 +1,6 @@
|
||||
// atmosphere · updates.js · Update chip, what's-new dialog and install progress for signed GitHub releases
|
||||
const Upd = { info: null, app: null, busy: false };
|
||||
const Upd = { info: null, app: null, busy: false, checkedAt: 0 };
|
||||
const UPDATE_EVERY = 6 * 3600 * 1000;
|
||||
|
||||
async function checkUpdates(manual = false) {
|
||||
const btn = $("#updateBtn");
|
||||
@@ -8,8 +9,10 @@ async function checkUpdates(manual = false) {
|
||||
btn.disabled = true;
|
||||
}
|
||||
try {
|
||||
Upd.checkedAt = Date.now();
|
||||
Upd.info = await invoke("update_check");
|
||||
renderUpdate();
|
||||
if (!manual) updateNotice();
|
||||
if (manual) {
|
||||
if (Upd.info) openUpdate();
|
||||
else toast("You're on the latest version.", "ok");
|
||||
@@ -38,6 +41,29 @@ function renderUpdate() {
|
||||
}
|
||||
}
|
||||
|
||||
function noticedVersion() {
|
||||
try { return localStorage.getItem("atmo.updateNoticed"); } catch { return null; }
|
||||
}
|
||||
|
||||
function updateNotice() {
|
||||
const u = Upd.info;
|
||||
if (!u || Upd.busy || $("#updateNotice") || noticedVersion() === u.version || (typeof Mini !== "undefined" && Mini.on)) return;
|
||||
try { localStorage.setItem("atmo.updateNoticed", u.version); } catch {}
|
||||
const first = (u.notes || "").split("\n").map((l) => l.replace(/^[-*#\s]+/, "").trim()).find(Boolean);
|
||||
const close = () => {
|
||||
el.classList.add("out");
|
||||
setTimeout(() => el.remove(), 200);
|
||||
};
|
||||
const el = h("div", { class: "update-notice", id: "updateNotice", role: "status" },
|
||||
h("span", { class: "un-icon" }, icon("sparkles")),
|
||||
h("div", { class: "un-text" }, h("strong", {}, `Atmosphere ${u.version} is out`), h("span", {}, first || "A new version is ready to install.")),
|
||||
h("div", { class: "un-actions" },
|
||||
h("button", { class: "btn small primary", type: "button", onclick: () => { close(); if (u.canInstall) installUpdate(); else invoke("open_link", { url: u.page }).catch(() => {}); } }, u.canInstall ? "Update and restart" : "Download"),
|
||||
h("button", { class: "btn small", type: "button", onclick: () => { close(); openUpdate(); } }, "What's new")),
|
||||
h("button", { class: "icon-btn un-close", type: "button", "aria-label": "Not now", title: "Not now. It stays in the sidebar.", onclick: close }, icon("x")));
|
||||
document.body.append(el);
|
||||
}
|
||||
|
||||
async function openUpdate() {
|
||||
const u = Upd.info;
|
||||
if (!u || Upd.busy) return;
|
||||
@@ -82,5 +108,8 @@ async function bindUpdates() {
|
||||
renderUpdate();
|
||||
$("#updateBtn")?.addEventListener("click", () => (Upd.info ? openUpdate() : checkUpdates(true)));
|
||||
$("#updateChip")?.addEventListener("click", openUpdate);
|
||||
if (state.settings?.checkUpdates !== false) setTimeout(() => checkUpdates(false), 5000);
|
||||
const auto = () => state.settings?.checkUpdates !== false && !Upd.busy;
|
||||
if (auto()) setTimeout(() => checkUpdates(false), 5000);
|
||||
setInterval(() => { if (auto() && Date.now() - Upd.checkedAt >= UPDATE_EVERY) checkUpdates(false); }, 15 * 60 * 1000);
|
||||
window.addEventListener("focus", () => { if (auto() && Upd.checkedAt && Date.now() - Upd.checkedAt >= UPDATE_EVERY) checkUpdates(false); });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user