Bump to v0.12.15 — install-aware update banner (Arch/deb/rpm get manual update guidance)

This commit is contained in:
Jure
2026-05-16 13:43:38 +02:00
parent 3757368990
commit 61c6703513
9 changed files with 104 additions and 14 deletions
+32 -9
View File
@@ -34,22 +34,45 @@ import { useUpdater } from "./hooks/useUpdater";
import { useKeyboardShortcuts } from "./hooks/useKeyboardShortcuts";
function UpdateBanner() {
const { available, version, installing, error, install, dismiss } = useUpdater();
const { available, version, installing, error, canSelfUpdate, kind, install, dismiss } = useUpdater();
const [copied, setCopied] = useState(false);
if (!available) return null;
const aurCmd = "yay -S vega-nostr-git";
return (
<div className="flex items-center justify-between px-4 py-2 bg-accent/10 border-b border-accent/30 text-[12px] shrink-0">
<span className="text-text">
Vega {version} is available.{" "}
Vega {version} is available.
{!canSelfUpdate && kind === "pacman" && (
<> Update with <code className="text-accent bg-bg-raised px-1 rounded-sm">{aurCmd}</code></>
)}
{error && <span className="text-danger ml-1">{error}</span>}
</span>
<div className="flex items-center gap-3">
<button
onClick={install}
disabled={installing}
className="text-accent hover:text-accent-hover transition-colors disabled:opacity-50"
>
{installing ? "Installing…" : "Update & restart"}
</button>
{canSelfUpdate ? (
<button
onClick={install}
disabled={installing}
className="text-accent hover:text-accent-hover transition-colors disabled:opacity-50"
>
{installing ? "Installing…" : "Update & restart"}
</button>
) : kind === "pacman" ? (
<button
onClick={() => navigator.clipboard.writeText(aurCmd).then(() => setCopied(true)).catch(() => {})}
className="text-accent hover:text-accent-hover transition-colors"
>
{copied ? "Copied" : "Copy command"}
</button>
) : (
<button
onClick={() => openUrl("https://github.com/hoornet/vega/releases/latest").catch(() => {})}
className="text-accent hover:text-accent-hover transition-colors"
>
View release
</button>
)}
<button onClick={dismiss} aria-label="Dismiss update" className="text-text-dim hover:text-text transition-colors">×</button>
</div>
</div>
+18
View File
@@ -1,6 +1,12 @@
import { useEffect, useState } from "react";
import { check } from "@tauri-apps/plugin-updater";
import { relaunch } from "@tauri-apps/plugin-process";
import { invoke } from "@tauri-apps/api/core";
interface InstallInfo {
can_self_update: boolean;
kind: string;
}
interface UpdateState {
available: boolean;
@@ -8,6 +14,8 @@ interface UpdateState {
body: string | null;
installing: boolean;
error: string | null;
canSelfUpdate: boolean;
kind: string;
install: () => Promise<void>;
dismiss: () => void;
}
@@ -19,6 +27,14 @@ export function useUpdater(): UpdateState {
const [installing, setInstalling] = useState(false);
const [error, setError] = useState<string | null>(null);
const [dismissed, setDismissed] = useState(false);
// Optimistic default: assume the updater works until the backend says otherwise.
const [installInfo, setInstallInfo] = useState<InstallInfo>({ can_self_update: true, kind: "updater" });
useEffect(() => {
invoke<InstallInfo>("install_info")
.then(setInstallInfo)
.catch(() => { /* keep optimistic default */ });
}, []);
useEffect(() => {
// Check for updates ~5 s after startup (non-blocking)
@@ -58,6 +74,8 @@ export function useUpdater(): UpdateState {
body,
installing,
error,
canSelfUpdate: installInfo.can_self_update,
kind: installInfo.kind,
install,
dismiss: () => setDismissed(true),
};