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

Function check

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

Source from the content-addressed store, hash-verified

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