feat(documents): add fetchDensity helper and /documents/+page.ts (#385)
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>
This commit is contained in:
9
frontend/src/routes/documents/+page.ts
Normal file
9
frontend/src/routes/documents/+page.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
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);
|
||||
};
|
||||
Reference in New Issue
Block a user