mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-09 03:04:54 -04:00
fix: all-recipes page now sorts alphabetically (#1405)
* added sort params to backend call * hardcoded alphabetical sort param * removed trivial type annotation * linters are friends, not food
This commit is contained in:
parent
d4b92a8ade
commit
bb1fa52d10
@ -61,8 +61,8 @@ export const useLazyRecipes = function () {
|
||||
|
||||
const recipes = ref<Recipe[]>([]);
|
||||
|
||||
async function fetchMore(start: number, limit: number) {
|
||||
const { data } = await api.recipes.getAll(start, limit);
|
||||
async function fetchMore(start: number, limit: number, orderBy: string | null = null, orderDescending = true) {
|
||||
const { data } = await api.recipes.getAll(start, limit, { orderBy, orderDescending });
|
||||
if (data) {
|
||||
data.forEach((recipe) => {
|
||||
recipes.value?.push(recipe);
|
||||
|
@ -22,8 +22,12 @@ import { useLazyRecipes } from "~/composables/recipes";
|
||||
export default defineComponent({
|
||||
components: { RecipeCardSection },
|
||||
setup() {
|
||||
const start = ref(0);
|
||||
// paging and sorting params
|
||||
const orderBy = "name";
|
||||
const orderDescending = false;
|
||||
const increment = ref(30);
|
||||
|
||||
const start = ref(0);
|
||||
const offset = ref(increment.value);
|
||||
const limit = ref(increment.value);
|
||||
const ready = ref(false);
|
||||
@ -32,7 +36,7 @@ export default defineComponent({
|
||||
const { recipes, fetchMore } = useLazyRecipes();
|
||||
|
||||
onMounted(async () => {
|
||||
await fetchMore(start.value, limit.value);
|
||||
await fetchMore(start.value, limit.value, orderBy, orderDescending);
|
||||
ready.value = true;
|
||||
});
|
||||
|
||||
@ -43,7 +47,7 @@ export default defineComponent({
|
||||
loading.value = true;
|
||||
start.value = offset.value + 1;
|
||||
offset.value = offset.value + increment.value;
|
||||
fetchMore(start.value, limit.value);
|
||||
fetchMore(start.value, limit.value, orderBy, orderDescending);
|
||||
loading.value = false;
|
||||
}, 500);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user