()
| 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); |
no test coverage detected