MCPcopy Create free account
hub / github.com/dailydotdev/apps / capture

Function capture

packages/shared/src/hooks/useRecentPages.ts:33–47  ·  view source on GitHub ↗
(url: string)

Source from the content-addressed store, hash-verified

31
32 let timeoutId: number | undefined;
33 const capture = (url: string) => {
34 if (router.pathname === '/posts/[id]') {
35 return;
36 }
37 const path = url.split('?')[0].split('#')[0];
38 // Only the latest navigation matters — drop any pending capture so
39 // rapid navigation doesn't stack timers or record stale titles.
40 window.clearTimeout(timeoutId);
41 timeoutId = window.setTimeout(() => {
42 const title = cleanTitle(document.title);
43 if (title) {
44 recordRecentPage({ path, title });
45 }
46 }, 250);
47 };
48
49 capture(router.asPath);
50 router.events.on('routeChangeComplete', capture);

Callers 1

useRecordRecentPagesFunction · 0.85

Calls 2

recordRecentPageFunction · 0.90
cleanTitleFunction · 0.85

Tested by

no test coverage detected