diff --git a/src/components/broadcast/broadcast-outputs-dialog.tsx b/src/components/broadcast/broadcast-outputs-dialog.tsx index 7621338..c5fdd0f 100644 --- a/src/components/broadcast/broadcast-outputs-dialog.tsx +++ b/src/components/broadcast/broadcast-outputs-dialog.tsx @@ -126,8 +126,22 @@ export function BroadcastOutputsDialog({ } } - const handleToggle = (output: BroadcastOutput, enabled: boolean) => + const handleToggle = (output: BroadcastOutput, enabled: boolean) => { + // Turning off an output while live kills what the congregation sees — + // make the operator confirm instead of doing it on one click. + if (!enabled && useBroadcastStore.getState().isLive) { + toast.warning("This is your live broadcast display", { + description: + "Closing it will stop what the congregation sees right now.", + action: { + label: "Close anyway", + onClick: () => void withBusy(output.id, () => disableOutput(output)), + }, + }) + return + } void withBusy(output.id, () => (enabled ? enableOutput(output) : disableOutput(output))) + } const handleRemove = (output: BroadcastOutput) => void withBusy(output.id, async () => { diff --git a/src/components/panels/live-output-panel.tsx b/src/components/panels/live-output-panel.tsx index 8d85813..f183b1c 100644 --- a/src/components/panels/live-output-panel.tsx +++ b/src/components/panels/live-output-panel.tsx @@ -1,4 +1,6 @@ import { useEffect } from "react" +import { toast } from "sonner" +import { getAllWindows } from "@tauri-apps/api/window" import { PanelHeader } from "@/components/ui/panel-header" import { CanvasVerse } from "@/components/ui/canvas-verse" import { Switch } from "@/components/ui/switch" @@ -7,6 +9,12 @@ import { useBroadcastStore, useBibleStore } from "@/stores" import { presentVerse, toVerseRenderData } from "@/hooks/use-broadcast" import { bibleActions } from "@/hooks/use-bible" +async function hasOpenBroadcastWindow(): Promise { + const windows = await getAllWindows() + // Output windows are labeled `broadcast-${outputId}` (see outputWindowLabel). + return windows.some((w) => w.label.startsWith("broadcast-")) +} + export function LiveOutputPanel() { const isLive = useBroadcastStore((s) => s.isLive) const autoLive = useBroadcastStore((s) => s.autoLive) @@ -50,6 +58,16 @@ export function LiveOutputPanel() { const selected = useBibleStore.getState().selectedVerse if (selected) void presentVerse(selected) } + if (checked) { + void hasOpenBroadcastWindow().then((open) => { + if (!open) { + toast.warning("No broadcast window open", { + description: + "Go live won't be visible to the congregation until you open a broadcast window in Broadcast Settings.", + }) + } + }) + } } return (