Add anonymous listening support and redesign web-player UI
Backend: - Expose GET /config/playback so the frontend can detect whether anonymous listening is enabled without requiring auth - Wire anonymous access through track streaming and YouTube resolve flows Frontend: - Allow browsing/listening without a session when the backend enables it - Redesign Inicio, Sidebar and top bar with a new dark theme, typography, and layout (top bar with live quick-search, sticky/blurred on scroll) - Populate Top música, Popular and Recomendados with real Musify + YouTube Music data instead of placeholders - Various shape, spacing, color and animation refinements across the redesigned components
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { createApiClient } from '$lib/server/api';
|
||||
|
||||
const CACHE_TTL_MS = 30_000;
|
||||
|
||||
let cached: { allowAnonymousListening: boolean; expiresAt: number } | null = null;
|
||||
|
||||
export async function getAllowAnonymousListening(fetchFn: typeof fetch): Promise<boolean> {
|
||||
if (cached && cached.expiresAt > Date.now()) return cached.allowAnonymousListening;
|
||||
|
||||
try {
|
||||
const api = createApiClient({ fetch: fetchFn });
|
||||
const { data } = await api.GET('/config/playback');
|
||||
const allowAnonymousListening = data?.allowAnonymousListening ?? false;
|
||||
|
||||
cached = { allowAnonymousListening, expiresAt: Date.now() + CACHE_TTL_MS };
|
||||
return allowAnonymousListening;
|
||||
} catch {
|
||||
// The API being unreachable shouldn't take down every page in the app;
|
||||
// fail closed (as if anonymous listening were off) and retry next time.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user