( lastViewAt: Date | string | undefined | null, hasReadToday: boolean, now: Date, awayMs: number, )
| 54 | |
| 55 | // Away = the last counted read is older than `awayMs` and nothing today yet. |
| 56 | export const isAway = ( |
| 57 | lastViewAt: Date | string | undefined | null, |
| 58 | hasReadToday: boolean, |
| 59 | now: Date, |
| 60 | awayMs: number, |
| 61 | ): boolean => { |
| 62 | if (!lastViewAt || hasReadToday) { |
| 63 | return false; |
| 64 | } |
| 65 | const last = new Date(lastViewAt).getTime(); |
| 66 | if (Number.isNaN(last)) { |
| 67 | return false; |
| 68 | } |
| 69 | return now.getTime() - last >= awayMs; |
| 70 | }; |
| 71 | |
| 72 | interface PatchyMoodInput { |
| 73 | state: StreakRingState; |
no outgoing calls
no test coverage detected