Skip to content

Commit adbcf80

Browse files
InterN0teCopilotgauthier-th
authored
fix(ui): remove duplicate download items in manage slide over (#1916)
* fix(ui): filter duplicate downloads in ManageSlideOver using downloadId Apply the same logic as PR #927 to deduplicate season pack downloads in the "Manage Series" slide-over panel. * Update src/components/ManageSlideOver/index.tsx Co-authored-by: Copilot <[email protected]> * Update src/components/ManageSlideOver/index.tsx Co-authored-by: Gauthier <[email protected]> --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Gauthier <[email protected]>
1 parent f91a26b commit adbcf80

File tree

1 file changed

+36
-20
lines changed

1 file changed

+36
-20
lines changed

src/components/ManageSlideOver/index.tsx

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
} from '@server/constants/media';
2626
import { MediaServerType } from '@server/constants/server';
2727
import type { MediaWatchDataResponse } from '@server/interfaces/api/mediaInterfaces';
28+
import type { DownloadingItem } from '@server/lib/downloadtracker';
2829
import type { RadarrSettings, SonarrSettings } from '@server/lib/settings';
2930
import type { MovieDetails } from '@server/models/Movie';
3031
import type { TvDetails } from '@server/models/Tv';
@@ -33,6 +34,17 @@ import Link from 'next/link';
3334
import { useIntl } from 'react-intl';
3435
import useSWR from 'swr';
3536

37+
const filterDuplicateDownloads = (
38+
items: DownloadingItem[] = []
39+
): DownloadingItem[] => {
40+
const seen = new Set<string>();
41+
return items.filter((item) => {
42+
if (seen.has(item.downloadId)) return false;
43+
seen.add(item.downloadId);
44+
return true;
45+
});
46+
};
47+
3648
const messages = defineMessages('components.ManageSlideOver', {
3749
manageModalTitle: 'Manage {mediaType}',
3850
manageModalIssues: 'Open Issues',
@@ -230,26 +242,30 @@ const ManageSlideOver = ({
230242
</h3>
231243
<div className="overflow-hidden rounded-md border border-gray-700 shadow">
232244
<ul>
233-
{data.mediaInfo?.downloadStatus?.map((status, index) => (
234-
<Tooltip
235-
key={`dl-status-${status.externalId}-${index}`}
236-
content={status.title}
237-
>
238-
<li className="border-b border-gray-700 last:border-b-0">
239-
<DownloadBlock downloadItem={status} />
240-
</li>
241-
</Tooltip>
242-
))}
243-
{data.mediaInfo?.downloadStatus4k?.map((status, index) => (
244-
<Tooltip
245-
key={`dl-status-${status.externalId}-${index}`}
246-
content={status.title}
247-
>
248-
<li className="border-b border-gray-700 last:border-b-0">
249-
<DownloadBlock downloadItem={status} is4k />
250-
</li>
251-
</Tooltip>
252-
))}
245+
{filterDuplicateDownloads(data.mediaInfo?.downloadStatus).map(
246+
(status, index) => (
247+
<Tooltip
248+
key={`dl-status-${status.externalId}-${index}`}
249+
content={status.title}
250+
>
251+
<li className="border-b border-gray-700 last:border-b-0">
252+
<DownloadBlock downloadItem={status} />
253+
</li>
254+
</Tooltip>
255+
)
256+
)}
257+
{filterDuplicateDownloads(data.mediaInfo?.downloadStatus4k).map(
258+
(status, index) => (
259+
<Tooltip
260+
key={`dl-status-4k-${status.externalId}-${index}`}
261+
content={status.title}
262+
>
263+
<li className="border-b border-gray-700 last:border-b-0">
264+
<DownloadBlock downloadItem={status} is4k />
265+
</li>
266+
</Tooltip>
267+
)
268+
)}
253269
</ul>
254270
</div>
255271
</div>

0 commit comments

Comments
 (0)