MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / RecordingModal

Function RecordingModal

frontend/src/components/forms/Recording.jsx:39–346  ·  view source on GitHub ↗
({
  recording = null,
  channel = null,
  isOpen,
  onClose,
})

Source from the content-addressed store, hash-verified

37} from '../../utils/forms/RecordingUtils.js';
38
39const RecordingModal = ({
40 recording = null,
41 channel = null,
42 isOpen,
43 onClose,
44}) => {
45 const fetchRecordings = useChannelsStore((s) => s.fetchRecordings);
46 const fetchRecurringRules = useChannelsStore((s) => s.fetchRecurringRules);
47
48 // All channels loaded via lightweight summary API
49 const [allChannels, setAllChannels] = useState([]);
50 const [isChannelsLoading, setIsChannelsLoading] = useState(false);
51
52 const [mode, setMode] = useState('single');
53 const [submitting, setSubmitting] = useState(false);
54
55 const singleForm = useForm({
56 mode: 'controlled',
57 initialValues: getSingleFormDefaults(recording, channel),
58 validate: singleFormValidators,
59 });
60
61 const recurringForm = useForm({
62 mode: 'controlled',
63 validateInputOnChange: false,
64 validateInputOnBlur: true,
65 initialValues: getRecurringFormDefaults(channel),
66 validate: recurringFormValidators,
67 });
68
69 useEffect(() => {
70 if (!isOpen) return;
71
72 if (recording?.id) {
73 setMode('single');
74 singleForm.setValues(getSingleFormDefaults(recording, channel));
75 } else {
76 singleForm.setValues(getSingleFormDefaults(null, channel));
77 recurringForm.setValues(getRecurringFormDefaults(channel));
78 setMode('single');
79 }
80 // eslint-disable-next-line react-hooks/exhaustive-deps
81 }, [isOpen, recording, channel]);
82
83 // Load all channels via lightweight summary API when modal opens
84 useEffect(() => {
85 let cancelled = false;
86 const run = async () => {
87 if (!isOpen) return;
88 try {
89 setIsChannelsLoading(true);
90 const chans = await getChannelsSummary();
91 if (cancelled) return;
92 setAllChannels(Array.isArray(chans) ? chans : []);
93 } catch (e) {
94 console.warn('Failed to load channels for recording form', e);
95 if (!cancelled) setAllChannels([]);
96 } finally {

Callers

nothing calls this directly

Calls 6

getSingleFormDefaultsFunction · 0.90
getRecurringFormDefaultsFunction · 0.90
sortedChannelOptionsFunction · 0.90
timeChangeFunction · 0.90
toTimeStringFunction · 0.90
runFunction · 0.70

Tested by

no test coverage detected