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

Function check

packages/shared/src/features/patchy/usePatchyAssistant.ts:350–376  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

348 return undefined;
349 }
350 const check = () => {
351 if (state !== 'at_risk' && state !== 'critical') {
352 return;
353 }
354 const [post] = getPatchyQuickReads(client, { limit: 1 });
355 const now = new Date();
356 const hours = getPatchyHoursLeftToday(now, user?.timezone);
357 queue({
358 kind: 'streak_risk',
359 text: post
360 ? `${hours} ${hours === 1 ? 'hour' : 'hours'} left on your streak. Here’s a ${post.readTime}-minute read:`
361 : `${hours} ${hours === 1 ? 'hour' : 'hours'} left on your streak. One quick read keeps it going.`,
362 primary: post ? 'Read it' : 'Find a quick read',
363 secondary: 'Not tonight',
364 post,
365 isOverModal: false,
366 notBefore: now.getTime(),
367 expiresAt: now.getTime() + 10 * 60 * 1000,
368 onPrimary: () => {
369 if (!post) {
370 goTo(`${webappUrl}posts`);
371 } else if (!openPatchyPost(post)) {
372 goTo(post.commentsPermalink);
373 }
374 },
375 });
376 };
377 check();
378 const id = setInterval(check, STREAK_CHECK_MS);
379 return () => clearInterval(id);

Callers 1

usePatchyAssistantFunction · 0.70

Calls 4

getPatchyQuickReadsFunction · 0.90
getPatchyHoursLeftTodayFunction · 0.90
openPatchyPostFunction · 0.90
goToFunction · 0.50

Tested by

no test coverage detected