mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-07-16 01:13:27 +01:00
refactor: downloads to minimize prop drilling and improve layout and design (#1337)
Co-authored-by: Alex Kim <alexkim@Alexs-MacBook-Pro.local> Co-authored-by: Fredrik Burmester <fredrik.burmester@gmail.com> Co-authored-by: Simon-Eklundh <simon.eklundh@proton.me>
This commit is contained in:
@@ -3,7 +3,7 @@ import type {
|
||||
PlaybackProgressInfo,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getPlaystateApi, getTvShowsApi } from "@jellyfin/sdk/lib/utils/api";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useAtomValue } from "jotai";
|
||||
import { useMemo } from "react";
|
||||
import { useDownload } from "@/providers/DownloadProvider";
|
||||
@@ -69,6 +69,7 @@ export const usePlaybackManager = ({
|
||||
const api = useAtomValue(apiAtom);
|
||||
const user = useAtomValue(userAtom);
|
||||
const { isConnected } = useNetworkStatus();
|
||||
const queryClient = useQueryClient();
|
||||
const { getDownloadedItemById, updateDownloadedItem, getDownloadedItems } =
|
||||
useDownload();
|
||||
|
||||
@@ -186,6 +187,9 @@ export const usePlaybackManager = ({
|
||||
},
|
||||
},
|
||||
});
|
||||
// Force invalidate queries so they refetch from updated local database
|
||||
queryClient.invalidateQueries({ queryKey: ["item", itemId] });
|
||||
queryClient.invalidateQueries({ queryKey: ["episodes"] });
|
||||
}
|
||||
|
||||
// Handle remote state update if online
|
||||
@@ -226,6 +230,9 @@ export const usePlaybackManager = ({
|
||||
},
|
||||
},
|
||||
});
|
||||
// Force invalidate queries so they refetch from updated local database
|
||||
queryClient.invalidateQueries({ queryKey: ["item", itemId] });
|
||||
queryClient.invalidateQueries({ queryKey: ["episodes"] });
|
||||
}
|
||||
|
||||
// Handle remote state update if online
|
||||
@@ -268,6 +275,9 @@ export const usePlaybackManager = ({
|
||||
},
|
||||
},
|
||||
});
|
||||
// Force invalidate queries so they refetch from updated local database
|
||||
queryClient.invalidateQueries({ queryKey: ["item", itemId] });
|
||||
queryClient.invalidateQueries({ queryKey: ["episodes"] });
|
||||
}
|
||||
|
||||
// Handle remote state update if online
|
||||
|
||||
Reference in New Issue
Block a user