Added AbortController to getRecipe params.
This commit is contained in:
parent
201ddb6656
commit
647a4be383
@ -3,6 +3,13 @@ import { ApiError } from './ApiError'
|
|||||||
import FullRecipeView, { RawFullRecipeView } from './types/FullRecipeView'
|
import FullRecipeView, { RawFullRecipeView } from './types/FullRecipeView'
|
||||||
import { toImageView } from './types/ImageView'
|
import { toImageView } from './types/ImageView'
|
||||||
|
|
||||||
|
export interface GetRecipeDeps {
|
||||||
|
token: string | null
|
||||||
|
username: string
|
||||||
|
slug: string
|
||||||
|
abortController: AbortController
|
||||||
|
}
|
||||||
|
|
||||||
const getRecipe = async (
|
const getRecipe = async (
|
||||||
token: string | null,
|
token: string | null,
|
||||||
ownerUsername: string,
|
ownerUsername: string,
|
||||||
|
@ -7,11 +7,16 @@ import getRecipe from '../../api/getRecipe'
|
|||||||
import Recipe from '../../pages/recipe/Recipe'
|
import Recipe from '../../pages/recipe/Recipe'
|
||||||
|
|
||||||
export const Route = createFileRoute('/recipes/$username/$slug')({
|
export const Route = createFileRoute('/recipes/$username/$slug')({
|
||||||
loader: ({ context, params }) =>
|
loader: ({ abortController, context, params }) =>
|
||||||
context.queryClient.ensureQueryData({
|
context.queryClient.ensureQueryData({
|
||||||
queryKey: ['recipe', params.username, params.slug],
|
queryKey: ['recipe', params.username, params.slug],
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
getRecipe(context.auth.token, params.username, params.slug)
|
getRecipe({
|
||||||
|
abortController,
|
||||||
|
token: context.auth.token,
|
||||||
|
username: params.username,
|
||||||
|
slug: params.slug
|
||||||
|
})
|
||||||
}),
|
}),
|
||||||
component() {
|
component() {
|
||||||
const recipe = useLoaderData({
|
const recipe = useLoaderData({
|
||||||
|
Loading…
Reference in New Issue
Block a user