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

Function capture

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

Source from the content-addressed store, hash-verified

51
52 let timeoutId: number | undefined;
53 const capture = (url: string) => {
54 if (withoutLayoutVariantPrefix(router.pathname) === '/posts/[id]') {
55 return;
56 }
57 const path = url.split('?')[0].split('#')[0];
58 // Only the latest navigation matters — drop any pending capture so
59 // rapid navigation doesn't stack timers or record stale titles.
60 window.clearTimeout(timeoutId);
61 timeoutId = window.setTimeout(() => {
62 const title = cleanTitle(document.title);
63 if (title) {
64 recordRecentPage({
65 path,
66 title,
67 type: typeForPathname(router.pathname),
68 });
69 }
70 }, 250);
71 };
72
73 capture(router.asPath);
74 router.events.on('routeChangeComplete', capture);

Callers 1

useRecordRecentPagesFunction · 0.70

Calls 4

recordRecentPageFunction · 0.90
cleanTitleFunction · 0.85
typeForPathnameFunction · 0.85

Tested by

no test coverage detected