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

Function filterGuideChannels

frontend/src/utils/guideUtils.js:142–175  ·  view source on GitHub ↗
(
  guideChannels,
  searchQuery,
  selectedGroupId,
  selectedProfileId,
  profiles
)

Source from the content-addressed store, hash-verified

140};
141
142export 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
177export const calculateEarliestProgramStart = (programs, defaultStart) => {
178 if (!programs.length) return defaultStart;

Callers 1

TVChannelGuideFunction · 0.90

Calls 1

filterMethod · 0.45

Tested by

no test coverage detected