summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLASER-Yi <[email protected]>2022-06-11 19:55:29 +0800
committerLASER-Yi <[email protected]>2022-06-11 19:55:29 +0800
commit98937a03786f64bcde5a35ab085cb6926b0a7e5e (patch)
tree0371e8bd474d5f5d1d629d1335be92d24832128a
parent3c53db7353137257e185e0361078b2a2eafb3701 (diff)
downloadbazarr-98937a03786f64bcde5a35ab085cb6926b0a7e5e.tar.gz
bazarr-98937a03786f64bcde5a35ab085cb6926b0a7e5e.zip
Fix crash when navigating from history view and open the history modal
-rw-r--r--frontend/src/apis/hooks/episodes.ts3
-rw-r--r--frontend/src/apis/hooks/movies.ts6
-rw-r--r--frontend/src/apis/queries/hooks.ts17
3 files changed, 16 insertions, 10 deletions
diff --git a/frontend/src/apis/hooks/episodes.ts b/frontend/src/apis/hooks/episodes.ts
index d67d2d194..c4f793047 100644
--- a/frontend/src/apis/hooks/episodes.ts
+++ b/frontend/src/apis/hooks/episodes.ts
@@ -99,7 +99,8 @@ export function useEpisodeDeleteBlacklist() {
export function useEpisodeHistoryPagination() {
return usePaginationQuery(
[QueryKeys.Series, QueryKeys.Episodes, QueryKeys.History],
- (param) => api.episodes.history(param)
+ (param) => api.episodes.history(param),
+ false
);
}
diff --git a/frontend/src/apis/hooks/movies.ts b/frontend/src/apis/hooks/movies.ts
index f75a40ad3..904f6557d 100644
--- a/frontend/src/apis/hooks/movies.ts
+++ b/frontend/src/apis/hooks/movies.ts
@@ -123,8 +123,10 @@ export function useMovieDeleteBlacklist() {
}
export function useMovieHistoryPagination() {
- return usePaginationQuery([QueryKeys.Movies, QueryKeys.History], (param) =>
- api.movies.history(param)
+ return usePaginationQuery(
+ [QueryKeys.Movies, QueryKeys.History],
+ (param) => api.movies.history(param),
+ false
);
}
diff --git a/frontend/src/apis/queries/hooks.ts b/frontend/src/apis/queries/hooks.ts
index 0b36421ea..649eeecbd 100644
--- a/frontend/src/apis/queries/hooks.ts
+++ b/frontend/src/apis/queries/hooks.ts
@@ -29,7 +29,8 @@ export function usePaginationQuery<
TQueryKey extends QueryKey = QueryKey
>(
queryKey: TQueryKey,
- queryFn: RangeQuery<TObject>
+ queryFn: RangeQuery<TObject>,
+ cacheIndividual = false
): UsePaginationQueryResult<TObject> {
const client = useQueryClient();
@@ -49,12 +50,14 @@ export function usePaginationQuery<
},
{
onSuccess: ({ data }) => {
- data.forEach((item) => {
- const id = GetItemId(item);
- if (id) {
- client.setQueryData([...queryKey, id], item);
- }
- });
+ if (cacheIndividual) {
+ data.forEach((item) => {
+ const id = GetItemId(item);
+ if (id) {
+ client.setQueryData([...queryKey, id], item);
+ }
+ });
+ }
},
}
);