Skip to content

Commit

Permalink
add tmdb to series update actions (#1004)
Browse files Browse the repository at this point in the history
  • Loading branch information
Terrails authored Aug 21, 2024
1 parent f82333c commit 5e07929
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import Action from '@/components/Collection/Series/EditSeriesTabs/Action';
import toast from '@/components/Toast';
import {
useRefreshSeriesAniDBInfoMutation,
useRefreshSeriesTMDBInfoMutation,
useRefreshSeriesTvdbInfoMutatation,
useUpdateSeriesTMDBImagesMutation,
} from '@/core/react-query/series/mutations';

type Props = {
Expand All @@ -14,6 +16,8 @@ type Props = {
const UpdateActionsTab = ({ seriesId }: Props) => {
const { mutate: refreshAnidb } = useRefreshSeriesAniDBInfoMutation();
const { mutate: refreshTvdb } = useRefreshSeriesTvdbInfoMutatation();
const { mutate: refreshTmdb } = useRefreshSeriesTMDBInfoMutation();
const { mutate: updateTmdbImages } = useUpdateSeriesTMDBImagesMutation();

const triggerAnidbRefresh = (force: boolean, cacheOnly: boolean) => {
refreshAnidb({ seriesId, force, cacheOnly }, {
Expand All @@ -31,6 +35,22 @@ const UpdateActionsTab = ({ seriesId }: Props) => {
onSuccess: () => toast.success('TvDB refresh queued!'),
})}
/>
<Action
name="Update TMDB Info"
description="Gets the latest series information from TMDB."
onClick={() =>
refreshTmdb(seriesId, {
onSuccess: () => toast.success('TMDB refresh queued!'),
})}
/>
<Action
name="Update TMDB Images - Force"
description="Forces a complete redownload of images from TMDB."
onClick={() =>
updateTmdbImages({ seriesId, force: true }, {
onSuccess: () => toast.success('TMDB image download queued!'),
})}
/>
<Action
name="Update AniDB Info"
description="Gets the latest series information from the AniDB database."
Expand Down
18 changes: 18 additions & 0 deletions src/core/react-query/series/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,21 @@ export const useWatchSeriesEpisodesMutation = () =>
invalidateQueries(['series', seriesId, 'episodes']);
},
});

export const useRefreshSeriesTMDBInfoMutation = () =>
useMutation({
mutationFn: (seriesId: number) =>
Promise.all([
axios.post(`Series/${seriesId}/TMDB/Show/Action/Refresh`),
axios.post(`Series/${seriesId}/TMDB/Movie/Action/Refresh`),
]),
});

export const useUpdateSeriesTMDBImagesMutation = () =>
useMutation({
mutationFn: ({ force = false, seriesId }: { seriesId: number, force: boolean }) =>
Promise.all([
axios.post(`Series/${seriesId}/TMDB/Show/Action/DownloadImages`, { force }),
axios.post(`Series/${seriesId}/TMDB/Movie/Action/DownloadImages`, { force }),
]),
});

0 comments on commit 5e07929

Please sign in to comment.