fix: deduplicate programs before counting in channel overview tabs (#1763)

The movie (and music video / other video)counts in the channel
overview were inflated because the same program was counted
once per lineup occurrence rather than once per unique program.
Episodes and tracks were unaffected since they already counted unique
shows/artists.
Adding uniqBy(uuid) before the groupBy fixes the count for
all tab types.

Fixes #1634.

Co-authored-by: Corey Vaillancourt <coreyjv@gmail.com>
This commit is contained in:
Corey Vaillancourt 2026-03-30 12:51:06 -04:00 committed by GitHub
parent 805b6eaa28
commit 92f3e0ab85
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,7 +6,7 @@ import {
ContentProgramTypeSchema,
type ContentProgramType,
} from '@tunarr/types/schemas';
import { groupBy, isNil, keys, mapValues, omitBy } from 'lodash-es';
import { groupBy, isNil, keys, mapValues, omitBy, uniqBy } from 'lodash-es';
import { useMemo, useState } from 'react';
import { useChannelAndProgramming } from '../../hooks/useChannelLineup.ts';
import { TabPanel } from '../TabPanel.tsx';
@ -99,14 +99,17 @@ export const ChannelPrograms = ({ channelId }: Props) => {
const programsByType = useMemo(
() =>
groupBy(
seq.collect(lineup, (p) => {
if (p.type === 'content' && p.id) {
return programs[p.id];
} else if (p.type === 'custom') {
return programs[p.id];
}
return;
}),
uniqBy(
seq.collect(lineup, (p) => {
if (p.type === 'content' && p.id) {
return programs[p.id];
} else if (p.type === 'custom') {
return programs[p.id];
}
return;
}),
(p) => p.id,
),
(p) => p.subtype,
),
[lineup, programs],