diff --git a/frontend/src/lib/types.ts b/frontend/src/lib/types.ts index 39cea8c..10b6a1b 100644 --- a/frontend/src/lib/types.ts +++ b/frontend/src/lib/types.ts @@ -85,7 +85,7 @@ export interface AssignedChore { id: string; famId: string; memberId: string | null; // null = shared with all members - shared?: boolean; // true = initially created as shared chore + shared?: boolean; // true = initially created as shared chore templateId?: string; frequency: Frequency; type: RewardType; @@ -216,5 +216,6 @@ export interface Session { famId: string; userId: string; memberName?: string; + username?: string; role?: string; } diff --git a/frontend/src/routes/[fam]/+layout.server.ts b/frontend/src/routes/[fam]/+layout.server.ts index 628ece6..a0de686 100644 --- a/frontend/src/routes/[fam]/+layout.server.ts +++ b/frontend/src/routes/[fam]/+layout.server.ts @@ -26,13 +26,16 @@ function actorFrom(session: { }; } -async function resolveChatIdentity(session: { - famId: string; - id: string; - role: string; - name?: string; - color?: string; -}, pbToken: string) { +async function resolveChatIdentity( + session: { + famId: string; + id: string; + role: string; + name?: string; + color?: string; + }, + pbToken: string +) { try { const s = createServices(createPbClient(pbToken)); const actor = actorFrom(session); @@ -51,7 +54,11 @@ export async function load(event) { let famId = ''; let chat: { famId: string; actor: ChatActor } | null = null; let fam: any = null; - let famAccess = { disabled: false, mode: 'none' as 'none' | 'code' | 'sub' | 'canceled', reason: '' }; + let famAccess = { + disabled: false, + mode: 'none' as 'none' | 'code' | 'sub' | 'canceled', + reason: '' + }; if (session && pbToken) { famId = session.famId; @@ -87,6 +94,7 @@ export async function load(event) { userId: session.id, memberName: session.name, memberColor: session.color || '', + username: session.username || '', role: session.role } : null, @@ -98,4 +106,4 @@ export async function load(event) { fam, famAccess }; -} \ No newline at end of file +} diff --git a/frontend/src/routes/[fam]/+layout.svelte b/frontend/src/routes/[fam]/+layout.svelte index 055a96d..8bf4be6 100644 --- a/frontend/src/routes/[fam]/+layout.svelte +++ b/frontend/src/routes/[fam]/+layout.svelte @@ -114,12 +114,14 @@ // session exists. $effect (not onMount) so it also fires when the session // appears after the layout was already mounted — e.g. a member redeeming // their OTP on /{fam}/join/{username} then landing on /{fam}/{username}. + // The handle comes from the session (not page.params) so jump-back-in lands + // on the user's own dashboard even from the bare /{fam} page. $effect(() => { if (!page.data.session) return; recordShortcut({ famSlug: (page.data.fam?.slug as string) || page.params.fam || '', famName: (page.data.fam?.name as string) || page.params.fam || '', - userName: page.data.role === 'parent' ? '' : page.params.username || '' + userName: page.data.session.username || page.params.username || '' }); });