mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-24 15:49:42 +02:00
fix: 2148 infinite scroll on search (#2173)
* refactor recipe card section to use unified query construct * rework search page so it uses lazy-loading of RecipeCardSection * remove RecipeQuery again * prettier reformatting * remove recipes/all page * remove max results setting from search * fix typing issues
This commit is contained in:
parent
afbee3a078
commit
541cdc79aa
16 changed files with 150 additions and 200 deletions
|
@ -55,9 +55,9 @@ const routes = {
|
|||
recipesSlugTimelineEventId: (slug: string, id: string) => `${prefix}/recipes/${slug}/timeline/events/${id}`,
|
||||
};
|
||||
|
||||
export type RecipeSearchQuery ={
|
||||
export type RecipeSearchQuery = {
|
||||
search: string;
|
||||
orderDirection? : "asc" | "desc";
|
||||
orderDirection?: "asc" | "desc";
|
||||
groupId?: string;
|
||||
|
||||
queryFilter?: string;
|
||||
|
@ -76,11 +76,10 @@ export type RecipeSearchQuery ={
|
|||
foods?: string[];
|
||||
requireAllFoods?: boolean;
|
||||
|
||||
page: number;
|
||||
perPage: number;
|
||||
page?: number;
|
||||
perPage?: number;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
export class RecipeAPI extends BaseCRUDAPI<CreateRecipe, Recipe, Recipe> {
|
||||
baseRoute: string = routes.recipesBase;
|
||||
|
@ -96,7 +95,7 @@ export class RecipeAPI extends BaseCRUDAPI<CreateRecipe, Recipe, Recipe> {
|
|||
this.share = new RecipeShareApi(requests);
|
||||
}
|
||||
|
||||
async search(rsq : RecipeSearchQuery) {
|
||||
async search(rsq: RecipeSearchQuery) {
|
||||
return await this.requests.get<PaginationData<Recipe>>(route(routes.recipesBase, rsq));
|
||||
}
|
||||
|
||||
|
@ -176,7 +175,10 @@ export class RecipeAPI extends BaseCRUDAPI<CreateRecipe, Recipe, Recipe> {
|
|||
}
|
||||
|
||||
async updateTimelineEvent(recipeSlug: string, eventId: string, payload: RecipeTimelineEventUpdate) {
|
||||
return await this.requests.put<RecipeTimelineEventOut, RecipeTimelineEventUpdate>(routes.recipesSlugTimelineEventId(recipeSlug, eventId), payload);
|
||||
return await this.requests.put<RecipeTimelineEventOut, RecipeTimelineEventUpdate>(
|
||||
routes.recipesSlugTimelineEventId(recipeSlug, eventId),
|
||||
payload
|
||||
);
|
||||
}
|
||||
|
||||
async deleteTimelineEvent(recipeSlug: string, eventId: string) {
|
||||
|
@ -184,8 +186,11 @@ export class RecipeAPI extends BaseCRUDAPI<CreateRecipe, Recipe, Recipe> {
|
|||
}
|
||||
|
||||
async getAllTimelineEvents(recipeSlug: string, page = 1, perPage = -1, params = {} as any) {
|
||||
return await this.requests.get<PaginationData<RecipeTimelineEventOut>>(routes.recipesSlugTimelineEvent(recipeSlug), {
|
||||
params: { page, perPage, ...params },
|
||||
});
|
||||
return await this.requests.get<PaginationData<RecipeTimelineEventOut>>(
|
||||
routes.recipesSlugTimelineEvent(recipeSlug),
|
||||
{
|
||||
params: { page, perPage, ...params },
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue