diff --git a/src/components/Collection/SeriesMetadata.tsx b/src/components/Collection/SeriesMetadata.tsx index 204404428..5e603ddcd 100644 --- a/src/components/Collection/SeriesMetadata.tsx +++ b/src/components/Collection/SeriesMetadata.tsx @@ -3,10 +3,13 @@ import { mdiCloseCircleOutline, mdiOpenInNew, mdiPencilCircleOutline, mdiPlusCir import { Icon } from '@mdi/react'; import Button from '@/components/Input/Button'; +import { useDeleteSeriesTvdbLinkMutation } from '@/core/rtkQuery/splitV3Api/seriesApi'; -const MetadataLink = ({ id, site }: { site: string, id: number | number[] }) => { +const MetadataLink = ({ id, seriesId, site }: { id: number | number[], seriesId: number, site: string }) => { const linkId = Array.isArray(id) ? id[0] : id; + const [disableTvDBTrigger] = useDeleteSeriesTvdbLinkMutation(); + const siteLink = useMemo(() => { switch (site) { case 'AniDB': @@ -24,6 +27,18 @@ const MetadataLink = ({ id, site }: { site: string, id: number | number[] }) => } }, [linkId, site]); + const canDisable = site === 'TvDB'; + + const disableMetadata = () => { + switch (site) { + case 'TvDB': + disableTvDBTrigger({ seriesId, tvdbShowId: linkId }).catch(() => {}); + break; + default: + break; + } + }; + return (
@@ -50,7 +65,7 @@ const MetadataLink = ({ id, site }: { site: string, id: number | number[] }) => - diff --git a/src/core/rtkQuery/splitV3Api/seriesApi.ts b/src/core/rtkQuery/splitV3Api/seriesApi.ts index ffccb3c67..5811c73fa 100644 --- a/src/core/rtkQuery/splitV3Api/seriesApi.ts +++ b/src/core/rtkQuery/splitV3Api/seriesApi.ts @@ -53,6 +53,15 @@ const seriesApi = splitV3Api.injectEndpoints({ invalidatesTags: ['SeriesUpdated'], }), + deleteSeriesTvdbLink: build.mutation({ + query: ({ seriesId, tvdbShowId }) => ({ + url: `Series/${seriesId}/TvDB`, + method: 'DELETE', + body: { ID: tvdbShowId }, + }), + invalidatesTags: ['SeriesUpdated', 'SeriesAniDB', 'SeriesEpisodes'], + }), + // Get a paginated list of Shoko.Server.API.v3.Models.Shoko.Series without local files, available to the current Shoko.Server.API.v3.Models.Shoko.User. getSeriesWithoutFiles: build.query, PaginationType>({ query: params => ({ url: 'Series/WithoutFiles', params }), @@ -231,6 +240,7 @@ const seriesApi = splitV3Api.injectEndpoints({ export const { useDeleteSeriesMutation, + useDeleteSeriesTvdbLinkMutation, useGetAniDBRecommendedAnimeQuery, useGetAniDBRelatedQuery, useGetAniDBSimilarQuery, diff --git a/src/pages/collection/series/SeriesOverview.tsx b/src/pages/collection/series/SeriesOverview.tsx index bdc8231cd..b26119220 100644 --- a/src/pages/collection/series/SeriesOverview.tsx +++ b/src/pages/collection/series/SeriesOverview.tsx @@ -32,6 +32,9 @@ const NextUpEpisode = ({ nextUpEpisode }: { nextUpEpisode: EpisodeType }) => { ); }; +// Links +const MetadataLinks = ['AniDB', 'TMDB', 'TvDB', 'TraktTv']; + const SeriesOverview = () => { const { seriesId } = useParams(); @@ -44,9 +47,6 @@ const SeriesOverview = () => { const similarData = useGetAniDBSimilarQuery({ seriesId: seriesId! }, { skip: !seriesId }); const similar: SeriesAniDBSimilarType[] = similarData?.data ?? [] as SeriesAniDBSimilarType[]; - // Links - const metadataLinks = ['AniDB', 'TMDB', 'TvDB', 'TraktTv']; - if (!seriesId || !series) return null; return ( @@ -68,11 +68,28 @@ const SeriesOverview = () => { transparent >
- {metadataLinks.map(site => ( -
- -
- ))} + {MetadataLinks.map((site) => { + const idOrIds = series.IDs[site] as number | number[]; + if (typeof idOrIds === 'number' || idOrIds.length === 0) { + const id = typeof idOrIds === 'number' ? idOrIds : idOrIds[0] || 0; + return ( +
+ +
+ ); + } + return idOrIds.map(id => ( +
+ +
+ )); + })}