diff --git a/TODO.md b/TODO.md index 63ee662f..70b96590 100644 --- a/TODO.md +++ b/TODO.md @@ -7,7 +7,7 @@ Order = impact. Font items + app.html preload intentionally skipped. - [x] 1. Lucide subpath imports — convert `from '@lucide/svelte'` barrel imports to `@lucide/svelte/icons/` so Vite tree-shakes per-icon (current 748 KB shared chunk) - [x] 2. Chart.js dynamic import in `FitnessChart.svelte` (drop 244 KB from non-stats fitness routes) - [x] 3. Recipe API endpoints — drop `JSON.parse(JSON.stringify(...))` double-serialize (9 endpoints). Client-side shuffle / cache headers deferred (would require rethinking hero preload + hydration) -- [ ] 4. Favorites page — drop unnecessary `all_brief` fetch (verify consumer first) +- [x] 4. Favorites page — drop unnecessary `all_brief` fetch (verified Search uses `favoritesOnly` so `allRecipes` was redundant) - [ ] 5. Replace redundant `locals.auth()` with `locals.session` across recipe/calendar/fitness loaders - [ ] 6. Stream fitness stats loader — return promises for slow panels - [ ] 7. Overview endpoint — add `.select(...)` projection, cap timeseries window diff --git a/package.json b/package.json index 202ba593..80afa286 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homepage", - "version": "1.46.15", + "version": "1.46.16", "private": true, "type": "module", "scripts": { diff --git a/src/routes/[recipeLang=recipeLang]/favorites/+page.server.ts b/src/routes/[recipeLang=recipeLang]/favorites/+page.server.ts index 9bf11a56..d3789e3d 100644 --- a/src/routes/[recipeLang=recipeLang]/favorites/+page.server.ts +++ b/src/routes/[recipeLang=recipeLang]/favorites/+page.server.ts @@ -3,7 +3,7 @@ import { redirect } from '@sveltejs/kit'; export const load: PageServerLoad = async ({ fetch, locals, params }) => { const apiBase = `/api/${params.recipeLang}`; - const session = await locals.auth(); + const session = locals.session ?? await locals.auth(); if (!session?.user?.nickname) { const callbackUrl = encodeURIComponent(`/${params.recipeLang}/favorites`); @@ -11,44 +11,25 @@ export const load: PageServerLoad = async ({ fetch, locals, params }) => { } try { - const [res, allRes] = await Promise.all([ - fetch(`${apiBase}/favorites/recipes`), - fetch(`${apiBase}/items/all_brief`) - ]); + const res = await fetch(`${apiBase}/favorites/recipes`); if (!res.ok) { return { favorites: [], - allRecipes: [], error: 'Failed to load favorites' }; } - const [favorites, allRecipes] = await Promise.all([res.json(), allRes.json()]); - - // Mark all favorites with isFavorite flag for filter compatibility - const favoritesWithFlag = favorites.map((recipe: any) => ({ - ...recipe, - isFavorite: true - })); - - // Get favorite IDs for marking in allRecipes - const favoriteIds = new Set(favoritesWithFlag.map((r: any) => r._id)); - const allRecipesWithFavorites = allRecipes.map((recipe: any) => ({ - ...recipe, - isFavorite: favoriteIds.has(recipe._id) - })); + const favorites = await res.json(); return { - favorites: favoritesWithFlag, - allRecipes: allRecipesWithFavorites, + favorites: favorites.map((recipe: any) => ({ ...recipe, isFavorite: true })), session }; } catch (e) { return { favorites: [], - allRecipes: [], error: 'Failed to load favorites' }; } -}; \ No newline at end of file +}; diff --git a/src/routes/[recipeLang=recipeLang]/favorites/+page.svelte b/src/routes/[recipeLang=recipeLang]/favorites/+page.svelte index 16f45bf2..4f9db2ca 100644 --- a/src/routes/[recipeLang=recipeLang]/favorites/+page.svelte +++ b/src/routes/[recipeLang=recipeLang]/favorites/+page.svelte @@ -33,12 +33,12 @@ function handleSearchResults(ids: Set, categories: Set) { matchedRecipeIds = ids; - hasActiveSearch = ids.size < (data.allRecipes?.length || data.favorites.length); + hasActiveSearch = ids.size < data.favorites.length; } const filteredFavorites = $derived.by(() => { if (!hasActiveSearch) return data.favorites; - return data.allRecipes.filter((r: any) => matchedRecipeIds.has(r._id)); + return data.favorites.filter((r: any) => matchedRecipeIds.has(r._id)); }); @@ -93,7 +93,7 @@ - + {#if data.error}

{labels.errorLoading} {data.error}