mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-25 08:09:41 +02:00
Feature/infinite scroll (#719)
* feat(frontend): ✨ lazy-load all recipes page * feat(frontend): ✨ enable runtime theme through env-variables * docs(docs): 📝 update v1 changelog * bump version Co-authored-by: Hayden <hay-kot@pm.me>
This commit is contained in:
parent
568215cf70
commit
c0dd07f9e7
21 changed files with 548 additions and 281 deletions
|
@ -57,6 +57,26 @@ export const useSorter = () => {
|
|||
};
|
||||
};
|
||||
|
||||
export const useLazyRecipes = function () {
|
||||
const api = useApiSingleton();
|
||||
|
||||
const recipes = ref<Recipe[] | null>([]);
|
||||
|
||||
async function fetchMore(start: number, limit: number) {
|
||||
const { data } = await api.recipes.getAll(start, limit);
|
||||
if (data) {
|
||||
data.forEach((recipe) => {
|
||||
recipes.value?.push(recipe);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
recipes,
|
||||
fetchMore,
|
||||
};
|
||||
};
|
||||
|
||||
export const useRecipes = (all = false, fetchRecipes = true) => {
|
||||
const api = useApiSingleton();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue