mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-22 06:39:41 +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
|
@ -1,5 +1,6 @@
|
|||
import { Recipe } from "../types/recipe";
|
||||
import { ApiRequestInstance, PaginationData } from "~/lib/api/types/non-generated";
|
||||
import { QueryValue, route } from "~/lib/api/base/route";
|
||||
|
||||
export interface CrudAPIInterface {
|
||||
requests: ApiRequestInstance;
|
||||
|
@ -21,14 +22,14 @@ export abstract class BaseAPI {
|
|||
|
||||
export abstract class BaseCRUDAPI<CreateType, ReadType, UpdateType = CreateType>
|
||||
extends BaseAPI
|
||||
implements CrudAPIInterface {
|
||||
implements CrudAPIInterface
|
||||
{
|
||||
abstract baseRoute: string;
|
||||
abstract itemRoute(itemId: string | number): string;
|
||||
|
||||
async getAll(page = 1, perPage = -1, params = {} as any) {
|
||||
return await this.requests.get<PaginationData<ReadType>>(this.baseRoute, {
|
||||
params: { page, perPage, ...params },
|
||||
});
|
||||
async getAll(page = 1, perPage = -1, params = {} as Record<string, QueryValue>) {
|
||||
params = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== null && v !== undefined));
|
||||
return await this.requests.get<PaginationData<ReadType>>(route(this.baseRoute, { page, perPage, ...params }));
|
||||
}
|
||||
|
||||
async createOne(payload: CreateType) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue