mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-01-15 11:17:49 +08:00
Fix inconsistent issues when backend trying to update episodes
This commit is contained in:
parent
ee7991b878
commit
8687646e9c
2 changed files with 32 additions and 2 deletions
|
@ -10,6 +10,8 @@ import api from "../raw";
|
|||
|
||||
const cacheEpisodes = (client: QueryClient, episodes: Item.Episode[]) => {
|
||||
episodes.forEach((item) => {
|
||||
client.setQueryData([QueryKeys.Episodes, item.sonarrEpisodeId], item);
|
||||
|
||||
client.setQueryData(
|
||||
[
|
||||
QueryKeys.Series,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import queryClient from "@/apis/queries";
|
||||
import { QueryKeys } from "@/apis/queries/keys";
|
||||
import { LOG } from "@/utilities/console";
|
||||
import { setCriticalError, setOnlineStatus } from "@/utilities/event";
|
||||
import { showNotification } from "@mantine/notifications";
|
||||
import { notification, task } from "../task";
|
||||
|
@ -36,11 +37,13 @@ export function createDefaultReducer(): SocketIO.Reducer[] {
|
|||
{
|
||||
key: "series",
|
||||
update: (ids) => {
|
||||
LOG("info", "Invalidating series", ids);
|
||||
ids.forEach((id) => {
|
||||
queryClient.invalidateQueries([QueryKeys.Series, id]);
|
||||
});
|
||||
},
|
||||
delete: (ids) => {
|
||||
LOG("info", "Invalidating series", ids);
|
||||
ids.forEach((id) => {
|
||||
queryClient.invalidateQueries([QueryKeys.Series, id]);
|
||||
});
|
||||
|
@ -49,11 +52,13 @@ export function createDefaultReducer(): SocketIO.Reducer[] {
|
|||
{
|
||||
key: "movie",
|
||||
update: (ids) => {
|
||||
LOG("info", "Invalidating movies", ids);
|
||||
ids.forEach((id) => {
|
||||
queryClient.invalidateQueries([QueryKeys.Movies, id]);
|
||||
});
|
||||
},
|
||||
delete: (ids) => {
|
||||
LOG("info", "Invalidating movies", ids);
|
||||
ids.forEach((id) => {
|
||||
queryClient.invalidateQueries([QueryKeys.Movies, id]);
|
||||
});
|
||||
|
@ -62,13 +67,36 @@ export function createDefaultReducer(): SocketIO.Reducer[] {
|
|||
{
|
||||
key: "episode",
|
||||
update: (ids) => {
|
||||
// Currently invalidate episodes is impossible because we don't directly fetch episodes (we fetch episodes by series id)
|
||||
// So we need to invalidate series instead
|
||||
// TODO: Make a query for episodes and invalidate that instead
|
||||
LOG("info", "Invalidating episodes", ids);
|
||||
ids.forEach((id) => {
|
||||
queryClient.invalidateQueries([QueryKeys.Episodes, id]);
|
||||
const episode = queryClient.getQueryData<Item.Episode>([
|
||||
QueryKeys.Episodes,
|
||||
id,
|
||||
]);
|
||||
if (episode !== undefined) {
|
||||
queryClient.invalidateQueries([
|
||||
QueryKeys.Series,
|
||||
episode.sonarrSeriesId,
|
||||
]);
|
||||
}
|
||||
});
|
||||
},
|
||||
delete: (ids) => {
|
||||
LOG("info", "Invalidating episodes", ids);
|
||||
ids.forEach((id) => {
|
||||
queryClient.invalidateQueries([QueryKeys.Episodes, id]);
|
||||
const episode = queryClient.getQueryData<Item.Episode>([
|
||||
QueryKeys.Episodes,
|
||||
id,
|
||||
]);
|
||||
if (episode !== undefined) {
|
||||
queryClient.invalidateQueries([
|
||||
QueryKeys.Series,
|
||||
episode.sonarrSeriesId,
|
||||
]);
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue