fix: try to fix invalidate cache in prod

This commit is contained in:
Fredrik Burmester
2024-11-26 21:54:35 +01:00
parent e8f4ee2264
commit 1fdf45daa7
2 changed files with 9 additions and 15 deletions

View File

@@ -5,6 +5,7 @@ import { ScrollingCollectionList } from "@/components/home/ScrollingCollectionLi
import { Loader } from "@/components/Loader";
import { MediaListSection } from "@/components/medialists/MediaListSection";
import { Colors } from "@/constants/Colors";
import { useRevalidatePlaybackProgressCache } from "@/hooks/useRevalidatePlaybackProgressCache";
import { useDownload } from "@/providers/DownloadProvider";
import { apiAtom, userAtom } from "@/providers/JellyfinProvider";
import { useSettings } from "@/utils/atoms/settings";
@@ -163,20 +164,13 @@ export default function index() {
);
}, [userViews]);
const invalidateCache = useRevalidatePlaybackProgressCache();
const refetch = useCallback(async () => {
setLoading(true);
await queryClient.invalidateQueries({
queryKey: ["home"],
type: "all",
exact: false,
});
await queryClient.invalidateQueries({
queryKey: ["item"],
type: "all",
exact: false,
});
await invalidateCache();
setLoading(false);
}, [queryClient]);
}, []);
const createCollectionConfig = useCallback(
(

View File

@@ -6,7 +6,7 @@ import { useQueryClient } from "@tanstack/react-query";
export function useRevalidatePlaybackProgressCache() {
const queryClient = useQueryClient();
const revalidate = () => {
const revalidate = async () => {
// List of all the queries to invalidate
const queriesToInvalidate = [
["item"],
@@ -20,9 +20,9 @@ export function useRevalidatePlaybackProgressCache() {
];
// Invalidate each query
queriesToInvalidate.forEach((queryKey) => {
queryClient.invalidateQueries({ queryKey });
});
for (const queryKey of queriesToInvalidate) {
await queryClient.invalidateQueries({ queryKey });
}
};
return revalidate;