({ channel: channelProp = null, isOpen, onClose })
| 94 | }; |
| 95 | |
| 96 | const ChannelForm = ({ channel: channelProp = null, isOpen, onClose }) => { |
| 97 | const theme = useMantineTheme(); |
| 98 | |
| 99 | const listRef = useRef(null); |
| 100 | const logoListRef = useRef(null); |
| 101 | const groupListRef = useRef(null); |
| 102 | |
| 103 | // Local copy so in-modal mutations (clear overrides, etc.) update the |
| 104 | // form immediately. Reset on each open from `channelProp`; mutated in |
| 105 | // place with API responses. |
| 106 | const [channel, setChannel] = useState(channelProp); |
| 107 | useEffect(() => { |
| 108 | setChannel(channelProp); |
| 109 | }, [channelProp]); |
| 110 | |
| 111 | const channelGroups = useChannelsStore((s) => s.channelGroups); |
| 112 | |
| 113 | const { |
| 114 | logos: channelLogos, |
| 115 | ensureLogosLoaded, |
| 116 | isLoading: logosLoading, |
| 117 | } = useChannelLogoSelection(); |
| 118 | |
| 119 | // Import the full logos store for duplicate checking |
| 120 | const allLogos = useLogosStore((s) => s.logos); |
| 121 | |
| 122 | // Ensure logos are loaded when component mounts |
| 123 | useEffect(() => { |
| 124 | ensureLogosLoaded(); |
| 125 | }, [ensureLogosLoaded]); |
| 126 | |
| 127 | const streamProfiles = useStreamProfilesStore((s) => s.profiles); |
| 128 | const epgs = useEPGsStore((s) => s.epgs); |
| 129 | const tvgs = useEPGsStore((s) => s.tvgs); |
| 130 | const tvgsById = useEPGsStore((s) => s.tvgsById); |
| 131 | |
| 132 | const [logoModalOpen, setLogoModalOpen] = useState(false); |
| 133 | const [channelStreams, setChannelStreams] = useState([]); |
| 134 | const [channelGroupModelOpen, setChannelGroupModalOpen] = useState(false); |
| 135 | const [epgPopoverOpened, setEpgPopoverOpened] = useState(false); |
| 136 | const [logoPopoverOpened, setLogoPopoverOpened] = useState(false); |
| 137 | const [selectedEPG, setSelectedEPG] = useState(''); |
| 138 | const [tvgFilter, setTvgFilter] = useState(''); |
| 139 | const [logoFilter, setLogoFilter] = useState(''); |
| 140 | |
| 141 | const [groupPopoverOpened, setGroupPopoverOpened] = useState(false); |
| 142 | const [groupFilter, setGroupFilter] = useState(''); |
| 143 | const [autoMatchLoading, setAutoMatchLoading] = useState(false); |
| 144 | const groupOptions = Object.values(channelGroups); |
| 145 | |
| 146 | const handleLogoSuccess = ({ logo }) => { |
| 147 | if (logo && logo.id) { |
| 148 | setValue('logo_id', logo.id); |
| 149 | ensureLogosLoaded(); // Refresh logos |
| 150 | } |
| 151 | setLogoModalOpen(false); |
| 152 | }; |
| 153 |
nothing calls this directly
no test coverage detected