Prevent fetching article before router params have been read

This prevents us from making an initial fetch with an undefined
slug and username that then returns a 400. This happens because
router isn't setup when we first make the call.
This commit is contained in:
Jackson Harper
2024-08-27 15:00:40 +08:00
parent 825da30d3d
commit 97657c5a79

View File

@ -677,10 +677,14 @@ export function useRefreshProcessingItems() {
return mutation
}
export const useGetLibraryItemContent = (username: string, slug: string) => {
export const useGetLibraryItemContent = (
username: string | undefined,
slug: string | undefined
) => {
const queryClient = useQueryClient()
return useQuery({
queryKey: ['libraryItem', slug],
enabled: !!username && !!slug,
queryFn: async () => {
const response = (await gqlFetcher(GQL_GET_LIBRARY_ITEM_CONTENT, {
slug,