fix: use authenticated user ID for habit service

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 13:55:48 -05:00
parent 56b8e9956a
commit ebdf569ba3
+6 -2
View File
@@ -1,5 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { HabitWithCompletions } from '$lib/context/habits.svelte'; import type { HabitWithCompletions } from '$lib/context/habits.svelte';
import type { User } from 'better-auth';
import HabitGrid from './HabitGrid.svelte'; import HabitGrid from './HabitGrid.svelte';
import HabitCreationForm from './HabitCreationForm.svelte'; import HabitCreationForm from './HabitCreationForm.svelte';
import { setHabitService } from '$lib/context/habits.svelte'; import { setHabitService } from '$lib/context/habits.svelte';
@@ -25,6 +26,8 @@
import { today, getLocalTimeZone } from '@internationalized/date'; import { today, getLocalTimeZone } from '@internationalized/date';
import { onMount } from 'svelte'; import { onMount } from 'svelte';
let { data }: { data: { user: User } } = $props();
let showCreateDialog = $state(false); let showCreateDialog = $state(false);
// Date selection state // Date selection state
@@ -34,8 +37,9 @@
// Habit visibility toggle // Habit visibility toggle
let showInactiveHabits = $state(false); let showInactiveHabits = $state(false);
// Create habit service instance - subscriptions will handle all data loading // Create habit service instance with authenticated user
const habitService = setHabitService('default-user'); // svelte-ignore state_referenced_locally
const habitService = setHabitService(data.user!.id);
// Simple loading state - just show skeleton briefly while subscriptions initialize // Simple loading state - just show skeleton briefly while subscriptions initialize
let loading = $state(true); let loading = $state(true);