From a486dfe34d1b74868eb32a22c15696c0737f26f7 Mon Sep 17 00:00:00 2001 From: Michael Genson <71845777+michael-genson@users.noreply.github.com> Date: Mon, 19 May 2025 21:04:03 +0000 Subject: [PATCH] fix janky cookbook links, probably --- frontend/components/Layout/DefaultLayout.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/components/Layout/DefaultLayout.vue b/frontend/components/Layout/DefaultLayout.vue index b38d248be..e644b677b 100644 --- a/frontend/components/Layout/DefaultLayout.vue +++ b/frontend/components/Layout/DefaultLayout.vue @@ -161,11 +161,11 @@ export default defineNuxtComponent({ if (!cookbooks.value) { return []; } - [...cookbooks.value].sort((a, b) => (a.position || 0) - (b.position || 0)); + const sortedCookbooks = [...cookbooks.value].sort((a, b) => (a.position || 0) - (b.position || 0)); const ownLinks: SideBarLink[] = []; const links: SideBarLink[] = []; - const cookbooksByHousehold = cookbooks.value.reduce((acc, cookbook) => { + const cookbooksByHousehold = sortedCookbooks.reduce((acc, cookbook) => { const householdName = householdsById.value[cookbook.householdId]?.name || ""; if (!acc[householdName]) { acc[householdName] = []; @@ -175,6 +175,10 @@ export default defineNuxtComponent({ }, {} as Record); Object.entries(cookbooksByHousehold).forEach(([householdName, cookbooks]) => { + if (!cookbooks.length) { + return; + } + if (cookbooks[0].householdId === currentUserHouseholdId.value) { ownLinks.push(...cookbooks.map(cookbookAsLink)); }