Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/components/broadcast/broadcast-outputs-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
18 changes: 18 additions & 0 deletions src/components/panels/live-output-panel.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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<boolean> {
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)
Expand Down Expand Up @@ -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 (
Expand Down