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 <175728472+Copilot@users.noreply.github.com> * Update src/components/ManageSlideOver/index.tsx Co-authored-by: Gauthier <mail@gauthierth.fr> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Gauthier <mail@gauthierth.fr>
This commit is contained in:
@@ -25,6 +25,7 @@ import {
|
|||||||
} from '@server/constants/media';
|
} from '@server/constants/media';
|
||||||
import { MediaServerType } from '@server/constants/server';
|
import { MediaServerType } from '@server/constants/server';
|
||||||
import type { MediaWatchDataResponse } from '@server/interfaces/api/mediaInterfaces';
|
import type { MediaWatchDataResponse } from '@server/interfaces/api/mediaInterfaces';
|
||||||
|
import type { DownloadingItem } from '@server/lib/downloadtracker';
|
||||||
import type { RadarrSettings, SonarrSettings } from '@server/lib/settings';
|
import type { RadarrSettings, SonarrSettings } from '@server/lib/settings';
|
||||||
import type { MovieDetails } from '@server/models/Movie';
|
import type { MovieDetails } from '@server/models/Movie';
|
||||||
import type { TvDetails } from '@server/models/Tv';
|
import type { TvDetails } from '@server/models/Tv';
|
||||||
@@ -33,6 +34,17 @@ import Link from 'next/link';
|
|||||||
import { useIntl } from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
|
|
||||||
|
const filterDuplicateDownloads = (
|
||||||
|
items: DownloadingItem[] = []
|
||||||
|
): DownloadingItem[] => {
|
||||||
|
const seen = new Set<string>();
|
||||||
|
return items.filter((item) => {
|
||||||
|
if (seen.has(item.downloadId)) return false;
|
||||||
|
seen.add(item.downloadId);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const messages = defineMessages('components.ManageSlideOver', {
|
const messages = defineMessages('components.ManageSlideOver', {
|
||||||
manageModalTitle: 'Manage {mediaType}',
|
manageModalTitle: 'Manage {mediaType}',
|
||||||
manageModalIssues: 'Open Issues',
|
manageModalIssues: 'Open Issues',
|
||||||
@@ -230,7 +242,8 @@ const ManageSlideOver = ({
|
|||||||
</h3>
|
</h3>
|
||||||
<div className="overflow-hidden rounded-md border border-gray-700 shadow">
|
<div className="overflow-hidden rounded-md border border-gray-700 shadow">
|
||||||
<ul>
|
<ul>
|
||||||
{data.mediaInfo?.downloadStatus?.map((status, index) => (
|
{filterDuplicateDownloads(data.mediaInfo?.downloadStatus).map(
|
||||||
|
(status, index) => (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
key={`dl-status-${status.externalId}-${index}`}
|
key={`dl-status-${status.externalId}-${index}`}
|
||||||
content={status.title}
|
content={status.title}
|
||||||
@@ -239,17 +252,20 @@ const ManageSlideOver = ({
|
|||||||
<DownloadBlock downloadItem={status} />
|
<DownloadBlock downloadItem={status} />
|
||||||
</li>
|
</li>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
))}
|
)
|
||||||
{data.mediaInfo?.downloadStatus4k?.map((status, index) => (
|
)}
|
||||||
|
{filterDuplicateDownloads(data.mediaInfo?.downloadStatus4k).map(
|
||||||
|
(status, index) => (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
key={`dl-status-${status.externalId}-${index}`}
|
key={`dl-status-4k-${status.externalId}-${index}`}
|
||||||
content={status.title}
|
content={status.title}
|
||||||
>
|
>
|
||||||
<li className="border-b border-gray-700 last:border-b-0">
|
<li className="border-b border-gray-700 last:border-b-0">
|
||||||
<DownloadBlock downloadItem={status} is4k />
|
<DownloadBlock downloadItem={status} is4k />
|
||||||
</li>
|
</li>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
))}
|
)
|
||||||
|
)}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user