add update context

This commit is contained in:
Eduard Gert
2026-05-11 17:21:38 +02:00
parent 1931a2c8a8
commit c8e18585c6
9 changed files with 122 additions and 75 deletions

View File

@@ -1,26 +1,16 @@
import { useState } from "react";
import { Button } from "@/components/Button";
import { useStatus } from "@/hooks/useStatus";
import { useClientVersion } from "@/modules/auto-update/ClientVersionContext";
import { cn } from "@/lib/cn";
import { Update as UpdateSvc } from "@bindings/services";
// TODO: Shown only when management has auto updates enabled + there are updates available + force updates is disabled
export const UpdateAvailableBanner = () => {
const { status } = useStatus();
const { updateVersion, triggerUpdate } = useClientVersion();
const [dismissed, setDismissed] = useState(false);
if (import.meta.env.DEV) return null;
const updateVersion = (status?.events ?? [])
.map((e) => e.metadata?.["new_version_available"])
.find((v): v is string => Boolean(v));
if (!updateVersion || dismissed) return null;
const triggerUpdate = () => {
UpdateSvc.Trigger().catch(() => {});
};
return (
<div
className={cn(