Compare commits

...

5 Commits

3 changed files with 9 additions and 7 deletions

View File

@ -929,13 +929,12 @@ export const useMacrosStore = create<MacrosState>((set, get) => ({
export interface FailsafeModeState {
isFailsafeMode: boolean;
reason: string | null; // "video", "network", etc.
setFailsafeMode: (active: boolean, reason: string | null) => void;
reason: string; // "video", "network", etc.
setFailsafeMode: (active: boolean, reason: string) => void;
}
export const useFailsafeModeStore = create<FailsafeModeState>(set => ({
isFailsafeMode: false,
reason: null,
setFailsafeMode: (active: boolean, reason: string | null) =>
set({ isFailsafeMode: active, reason }),
reason: "",
setFailsafeMode: (active, reason) => set({ isFailsafeMode: active, reason }),
}));

View File

@ -3,6 +3,7 @@ import { useCallback, useState } from "react";
import { useJsonRpc } from "@/hooks/useJsonRpc";
import { Button } from "@components/Button";
import { useFailsafeModeStore } from "@/hooks/stores";
import LoadingSpinner from "../components/LoadingSpinner";
import { useDeviceUiNavigation } from "../hooks/useAppNavigation";
@ -15,6 +16,7 @@ export default function SettingsGeneralRebootRoute() {
const { send } = useJsonRpc();
const [isRebooting, setIsRebooting] = useState(false);
const { navigateTo } = useDeviceUiNavigation();
const { setFailsafeMode } = useFailsafeModeStore();
const onConfirmUpdate = useCallback(async () => {
setIsRebooting(true);
@ -22,8 +24,9 @@ export default function SettingsGeneralRebootRoute() {
send("reboot", { force: true });
await new Promise(resolve => setTimeout(resolve, REBOOT_REDIRECT_DELAY_MS));
setFailsafeMode(false, "");
navigateTo("/");
}, [navigateTo, send]);
}, [navigateTo, send, setFailsafeMode]);
{
/* TODO: Migrate to using URLs instead of the global state. To simplify the refactoring, we'll keep the global state for now. */

View File

@ -853,7 +853,7 @@ export default function KvmIdRoute() {
/>
<div className="relative flex h-full w-full overflow-hidden">
{!isFailsafeMode && failsafeReason === "video" && <WebRTCVideo />}
{(isFailsafeMode && failsafeReason === "video") ? null : <WebRTCVideo />}
<div
style={{ animationDuration: "500ms" }}
className="animate-slideUpFade pointer-events-none absolute inset-0 flex items-center justify-center p-4"