audio streaming app plyr.fm
38
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: use auth singleton in library/liked pages after layout simplification (#782)

After PR #781 simplified +layout.ts to no longer provide isAuthenticated
in layout data, pages using `await parent()` to check auth were broken
(isAuthenticated was undefined, always redirecting to /).

Changed library/+page.ts and liked/+page.ts to use the auth singleton
directly via `await auth.initialize()` - consistent with how +layout.svelte
now handles auth.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

authored by

nate nowack
Claude Opus 4.5
and committed by
GitHub
1cb1787e 45357828

+10 -9
+5 -4
frontend/src/routes/library/+page.ts
··· 1 1 import { browser } from '$app/environment'; 2 2 import { redirect } from '@sveltejs/kit'; 3 3 import { API_URL } from '$lib/config'; 4 + import { auth } from '$lib/auth.svelte'; 4 5 import type { LoadEvent } from '@sveltejs/kit'; 5 6 import type { Playlist, Track } from '$lib/types'; 6 7 ··· 11 12 12 13 export const ssr = false; 13 14 14 - export async function load({ parent, fetch }: LoadEvent): Promise<PageData> { 15 + export async function load({ fetch }: LoadEvent): Promise<PageData> { 15 16 if (!browser) { 16 17 return { likedCount: 0, playlists: [] }; 17 18 } 18 19 19 - // check auth from parent layout data 20 - const { isAuthenticated } = await parent(); 21 - if (!isAuthenticated) { 20 + // ensure auth is initialized before checking 21 + await auth.initialize(); 22 + if (!auth.isAuthenticated) { 22 23 throw redirect(302, '/'); 23 24 } 24 25
+5 -5
frontend/src/routes/liked/+page.ts
··· 1 1 import { browser } from '$app/environment'; 2 2 import { redirect } from '@sveltejs/kit'; 3 3 import { fetchLikedTracks } from '$lib/tracks.svelte'; 4 + import { auth } from '$lib/auth.svelte'; 4 5 import type { Track } from '$lib/types'; 5 - import type { LoadEvent } from '@sveltejs/kit'; 6 6 7 7 export interface PageData { 8 8 tracks: Track[]; ··· 10 10 11 11 export const ssr = false; 12 12 13 - export async function load({ parent }: LoadEvent): Promise<PageData> { 13 + export async function load(): Promise<PageData> { 14 14 if (!browser) { 15 15 return { tracks: [] }; 16 16 } 17 17 18 - // check auth from parent layout data 19 - const { isAuthenticated } = await parent(); 20 - if (!isAuthenticated) { 18 + // ensure auth is initialized before checking 19 + await auth.initialize(); 20 + if (!auth.isAuthenticated) { 21 21 throw redirect(302, '/'); 22 22 } 23 23