The density data is fetched only on tablet/desktop (sm:+ breakpoint) and when ?view=calendar is not set — mobile users and the future calendar view (#386) skip the request entirely. Lives in +page.ts (client-side) so the matchMedia gate can run in the browser; +page.server.ts continues to handle the document search. Non-ok responses and network failures degrade to an empty bucket list rather than throwing, so the document list keeps rendering. 5 unit tests cover the gating + graceful degradation paths. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
10 lines
378 B
TypeScript
10 lines
378 B
TypeScript
import { browser } from '$app/environment';
|
|
import { fetchDensity } from '$lib/document/timeline';
|
|
import type { PageLoad } from './$types';
|
|
|
|
export const load: PageLoad = async ({ url, fetch }) => {
|
|
const view = url.searchParams.get('view');
|
|
const isDesktop = browser && window.matchMedia('(min-width: 640px)').matches;
|
|
return await fetchDensity(fetch, view, isDesktop);
|
|
};
|