From 75fbf9639a284860f123fa2cdf0530ca5781ca8a Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Sun, 21 Sep 2025 16:23:07 -0500 Subject: [PATCH] Enhancement: Update channel and program mapping to support multiple channels per TVG ID --- frontend/src/pages/Guide.jsx | 15 +++++++++------ frontend/src/pages/guideUtils.js | 24 ++++++++++++++++-------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/frontend/src/pages/Guide.jsx b/frontend/src/pages/Guide.jsx index 9c90bb1d..50bd1222 100644 --- a/frontend/src/pages/Guide.jsx +++ b/frontend/src/pages/Guide.jsx @@ -207,7 +207,9 @@ const GuideRow = React.memo(({ index, style, data }) => { }} > {channelPrograms.length > 0 ? ( - channelPrograms.map((program) => renderProgram(program)) + channelPrograms.map((program) => + renderProgram(program, undefined, channel) + ) ) : ( <> {Array.from({ length: Math.ceil(24 / 2) }).map( @@ -599,11 +601,12 @@ export default function TVChannelGuide({ startDate, endDate }) { const findChannelByTvgId = useCallback( (tvgId) => { - const channelId = channelIdByTvgId.get(String(tvgId)); - if (!channelId) { + const channelIds = channelIdByTvgId.get(String(tvgId)); + if (!channelIds || channelIds.length === 0) { return null; } - return channelById.get(channelId) || null; + // Return the first channel that matches this TVG ID + return channelById.get(channelIds[0]) || null; }, [channelById, channelIdByTvgId] ); @@ -844,7 +847,7 @@ export default function TVChannelGuide({ startDate, endDate }) { [start, syncScrollLeft] ); const renderProgram = useCallback( - (program, channelStart = start) => { + (program, channelStart = start, channel = null) => { const programStartMs = program.startMs ?? dayjs(program.start_time).valueOf(); const programEndMs = program.endMs ?? dayjs(program.end_time).valueOf(); @@ -887,7 +890,7 @@ export default function TVChannelGuide({ startDate, endDate }) { return ( { - const channelId = channelIdByTvgId.get(String(program.tvg_id)); - if (!channelId) { + const channelIds = channelIdByTvgId.get(String(program.tvg_id)); + if (!channelIds || channelIds.length === 0) { return; } - if (!map.has(channelId)) { - map.set(channelId, []); - } - const startMs = program.startMs ?? dayjs(program.start_time).valueOf(); const endMs = program.endMs ?? dayjs(program.end_time).valueOf(); - map.get(channelId).push({ + const programData = { ...program, startMs, endMs, + }; + + // Add this program to all channels that share the same TVG ID + channelIds.forEach((channelId) => { + if (!map.has(channelId)) { + map.set(channelId, []); + } + map.get(channelId).push(programData); }); });