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

Function capture

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

Source from the content-addressed store, hash-verified

72
73 let timeoutId: number | undefined;
74 const capture = (url: string) => {
75 if (withoutLayoutVariantPrefix(router.pathname) === '/posts/[id]') {
76 return;
77 }
78 const path = url.split('?')[0].split('#')[0];
79 // Only the latest navigation matters — drop any pending capture so
80 // rapid navigation doesn't stack timers or record stale titles.
81 window.clearTimeout(timeoutId);
82 timeoutId = window.setTimeout(() => {
83 const title = cleanTitle(document.title);
84 if (title) {
85 recordRecentPage({
86 path,
87 title,
88 type: typeForPathname(router.pathname),
89 });
90 }
91 }, 250);
92 };
93
94 capture(router.asPath);
95 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