mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-11-02 02:03:20 -05: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:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user