mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-01-23 10:45:27 +00:00
Enhancement: Update channel and program mapping to support multiple channels per TVG ID
This commit is contained in:
parent
4db8eca391
commit
75fbf9639a
2 changed files with 25 additions and 14 deletions
|
|
@ -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 (
|
||||
<Box
|
||||
className="guide-program-container"
|
||||
key={`${program.tvg_id}-${program.start_time}`}
|
||||
key={`${channel?.id || 'unknown'}-${program.id || `${program.tvg_id}-${program.start_time}`}`}
|
||||
style={{
|
||||
position: 'absolute',
|
||||
left: leftPx + gapSize,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,11 @@ export function buildChannelIdMap(channels, tvgsById) {
|
|||
: null;
|
||||
const tvgId = tvgRecord?.tvg_id ?? channel.uuid;
|
||||
if (tvgId) {
|
||||
map.set(String(tvgId), channel.id);
|
||||
const tvgKey = String(tvgId);
|
||||
if (!map.has(tvgKey)) {
|
||||
map.set(tvgKey, []);
|
||||
}
|
||||
map.get(tvgKey).push(channel.id);
|
||||
}
|
||||
});
|
||||
return map;
|
||||
|
|
@ -24,22 +28,26 @@ export function mapProgramsByChannel(programs, channelIdByTvgId) {
|
|||
|
||||
const map = new Map();
|
||||
programs.forEach((program) => {
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue