update: hide empty claimed wishlists, move local wishlists, cleanup comments

This commit is contained in:
2025-12-21 17:37:54 +01:00
parent 0b1e2b8dd3
commit d046c66bc7
4 changed files with 7 additions and 24 deletions

View File

@@ -21,11 +21,9 @@
let localWishlists = $state<LocalWishlist[]>([]);
let enrichedWishlists = $state<any[]>([]);
// Load local wishlists on mount and fetch their data from server
onMount(async () => {
localWishlists = getLocalWishlists();
// Fetch full wishlist data for each local wishlist
const promises = localWishlists.map(async (local) => {
try {
const response = await fetch(`/api/wishlist/${local.ownerToken}`);
@@ -39,7 +37,6 @@
} catch (error) {
console.error('Failed to fetch wishlist data:', error);
}
// Fallback to local data if fetch fails
return {
id: local.ownerToken,
title: local.title,

View File

@@ -36,7 +36,6 @@ export function addLocalWishlist(wishlist: LocalWishlist): void {
try {
const wishlists = getLocalWishlists();
// Check if already exists
const exists = wishlists.some(w => w.ownerToken === wishlist.ownerToken);
if (exists) return;

View File

@@ -147,7 +147,6 @@ export const actions: Actions = {
return { success: false, error: 'Wishlist ID is required' };
}
// Verify the user owns this wishlist
await db.delete(wishlists)
.where(and(
eq(wishlists.id, wishlistId),

View File

@@ -11,12 +11,10 @@
let { data }: { data: PageData } = $props();
// For anonymous users, get theme from localStorage
function getInitialTheme() {
if (data.isAuthenticated) {
return data.user?.dashboardTheme || 'none';
} else {
// Anonymous user - get from localStorage
if (typeof window !== 'undefined') {
return localStorage.getItem('dashboardTheme') || 'none';
}
@@ -24,12 +22,10 @@
}
}
// For anonymous users, get color from localStorage
function getInitialColor() {
if (data.isAuthenticated) {
return data.user?.dashboardColor || null;
} else {
// Anonymous user - get from localStorage
if (typeof window !== 'undefined') {
return localStorage.getItem('dashboardColor') || null;
}
@@ -40,7 +36,6 @@
let currentTheme = $state(getInitialTheme());
let currentColor = $state(getInitialColor());
// Save to localStorage when theme changes for anonymous users
function handleThemeUpdate(theme: string | null) {
currentTheme = theme || 'none';
@@ -49,7 +44,6 @@
}
}
// Save to localStorage when color changes for anonymous users
function handleColorUpdate(color: string | null) {
currentColor = color;
@@ -64,10 +58,8 @@
const t = $derived(languageStore.t);
// Only owned wishlists for "My Wishlists"
const myWishlists = $derived(() => data.wishlists || []);
// Claimed wishlists (those with ownerToken, meaning they were claimed via edit link)
const claimedWishlists = $derived(() => {
return (data.savedWishlists || [])
.filter(saved => saved.wishlist?.ownerToken)
@@ -79,7 +71,6 @@
}));
});
// Saved wishlists are those WITHOUT ownerToken (saved from public view only)
const savedWishlists = $derived(() => {
return (data.savedWishlists || []).filter(saved => !saved.wishlist?.ownerToken);
});
@@ -96,15 +87,7 @@
onColorUpdate={handleColorUpdate}
/>
<!-- Local Wishlists Section (for anonymous and authenticated users) -->
<LocalWishlistsSection
isAuthenticated={data.isAuthenticated}
fallbackColor={currentColor}
fallbackTheme={currentTheme}
/>
{#if data.isAuthenticated}
<!-- My Wishlists Section -->
<WishlistSection
title={t.dashboard.myWishlists}
description={t.dashboard.myWishlistsDescription}
@@ -162,7 +145,12 @@
{/snippet}
</WishlistSection>
<!-- Claimed Wishlists Section -->
<LocalWishlistsSection
isAuthenticated={data.isAuthenticated}
fallbackColor={currentColor}
fallbackTheme={currentTheme}
/>
<WishlistSection
title={t.dashboard.claimedWishlists}
description={t.dashboard.claimedWishlistsDescription}
@@ -219,7 +207,6 @@
{/snippet}
</WishlistSection>
<!-- Saved Wishlists Section -->
<WishlistSection
title={t.dashboard.savedWishlists}
description={t.dashboard.savedWishlistsDescription}
@@ -228,6 +215,7 @@
emptyDescription={t.dashboard.emptySavedWishlistsDescription}
fallbackColor={currentColor}
fallbackTheme={currentTheme}
hideIfEmpty={true}
>
{#snippet actions(saved, unlocked)}
<div class="flex gap-2 flex-wrap">