( guideChannels, searchQuery, selectedGroupId, selectedProfileId, profiles )
| 140 | }; |
| 141 | |
| 142 | export const filterGuideChannels = ( |
| 143 | guideChannels, |
| 144 | searchQuery, |
| 145 | selectedGroupId, |
| 146 | selectedProfileId, |
| 147 | profiles |
| 148 | ) => { |
| 149 | return guideChannels.filter((channel) => { |
| 150 | // Search filter |
| 151 | if (searchQuery) { |
| 152 | if (!channel.name.toLowerCase().includes(searchQuery.toLowerCase())) |
| 153 | return false; |
| 154 | } |
| 155 | |
| 156 | // Channel group filter |
| 157 | if (selectedGroupId !== 'all') { |
| 158 | if (channel.channel_group_id !== parseInt(selectedGroupId)) return false; |
| 159 | } |
| 160 | |
| 161 | // Profile filter |
| 162 | if (selectedProfileId !== 'all') { |
| 163 | const profileChannels = profiles[selectedProfileId]?.channels || []; |
| 164 | const enabledChannelIds = Array.isArray(profileChannels) |
| 165 | ? profileChannels.filter((pc) => pc.enabled).map((pc) => pc.id) |
| 166 | : profiles[selectedProfileId]?.channels instanceof Set |
| 167 | ? Array.from(profiles[selectedProfileId].channels) |
| 168 | : []; |
| 169 | |
| 170 | if (!enabledChannelIds.includes(channel.id)) return false; |
| 171 | } |
| 172 | |
| 173 | return true; |
| 174 | }); |
| 175 | }; |
| 176 | |
| 177 | export const calculateEarliestProgramStart = (programs, defaultStart) => { |
| 178 | if (!programs.length) return defaultStart; |
no test coverage detected