Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ability to Select Default Poster/Fanart/Banner. #678

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/core/rtkQuery/splitV3Api/seriesApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@ const seriesApi = splitV3Api.injectEndpoints({
}),
}),

changeSeriesImage: build.mutation<ResponseType, { seriesId: string, imageType: string, params: object }>({
ElementalCrisis marked this conversation as resolved.
Show resolved Hide resolved
query: ({ imageType, params, seriesId }) => ({
url: `Series/${seriesId}/Images/${imageType}`,
method: 'PUT',
body: params,
}),
invalidatesTags: ['SeriesAniDB'],
}),
ElementalCrisis marked this conversation as resolved.
Show resolved Hide resolved

// Queue a refresh of all the TvDB data linked to a series using the seriesID.
refreshSeriesTvdbInfo: build.mutation<boolean, { seriesId: number, force?: boolean }>({
query: ({ force = false, seriesId }) => ({
Expand Down Expand Up @@ -230,6 +239,7 @@ const seriesApi = splitV3Api.injectEndpoints({
});

export const {
useChangeSeriesImageMutation,
useDeleteSeriesMutation,
useGetAniDBRecommendedAnimeQuery,
useGetAniDBRelatedQuery,
Expand Down
16 changes: 13 additions & 3 deletions src/pages/collection/series/SeriesImages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import BackgroundImagePlaceholderDiv from '@/components/BackgroundImagePlacehold
import Button from '@/components/Input/Button';
import Checkbox from '@/components/Input/Checkbox';
import ShokoPanel from '@/components/Panels/ShokoPanel';
import { useGetSeriesImagesQuery } from '@/core/rtkQuery/splitV3Api/seriesApi';
import toast from '@/components/Toast';
import { useChangeSeriesImageMutation, useGetSeriesImagesQuery } from '@/core/rtkQuery/splitV3Api/seriesApi';

import type { ImageType } from '@/core/types/api/common';

Expand Down Expand Up @@ -60,8 +61,8 @@ const SeriesImages = () => {

const [type, setType] = useState('Posters');
const [selectedImage, setSelectedImage] = useState<ImageType>({} as ImageType);

const imagesData = useGetSeriesImagesQuery({ seriesId: seriesId! }, { skip: !seriesId });
const [changeImage] = useChangeSeriesImageMutation();
const images = imagesData.data;

const splitPath = split(selectedImage?.RelativeFilepath ?? '-', '/');
Expand Down Expand Up @@ -96,7 +97,16 @@ const SeriesImages = () => {
<Button
buttonType="primary"
className="rounded-md border border-panel-border px-4 py-3 font-semibold"
disabled
disabled={!Object.keys(selectedImage).length}
ElementalCrisis marked this conversation as resolved.
Show resolved Hide resolved
onClick={() => {
changeImage({
seriesId,
imageType: selectedImage.Type,
params: { ID: selectedImage.ID, Source: selectedImage.Source },
})
.then(() => toast.success(`Series ${selectedImage.Type} has been changed.`))
.catch(console.error);
}}
>
Set As Series Poster
ElementalCrisis marked this conversation as resolved.
Show resolved Hide resolved
</Button>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/collection/series/SeriesTags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const SeriesTags = () => {
</div>
</div>
<div className="grid grid-cols-3 gap-8">
{map(tags, item => <SeriesTag item={item} />)}
{map(tags, item => <SeriesTag key={item.ID} item={item} />)}
</div>
</div>
</div>
Expand Down