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