({
state,
hasReadToday,
lastViewAt,
now,
config,
}: PatchyMoodInput)
| 79 | |
| 80 | // Never sad, never guilt: the worst he gets is asleep. |
| 81 | export const getPatchyMood = ({ |
| 82 | state, |
| 83 | hasReadToday, |
| 84 | lastViewAt, |
| 85 | now, |
| 86 | config, |
| 87 | }: PatchyMoodInput): PatchyMood => { |
| 88 | if (isAway(lastViewAt, hasReadToday, now, config.awayMs)) { |
| 89 | return 'away'; |
| 90 | } |
| 91 | if (isLateNight(now, config.lateNight)) { |
| 92 | return 'sleepy'; |
| 93 | } |
| 94 | if (state === 'freeze') { |
| 95 | return 'resting'; |
| 96 | } |
| 97 | if (hasReadToday || state === 'celebration') { |
| 98 | return 'happy'; |
| 99 | } |
| 100 | return 'ready'; |
| 101 | }; |
| 102 | |
| 103 | // Repeating the same action in one day escalates: the third upvote or |
| 104 | // bookmark of the day (and every fifth after that) gets the bigger reaction. |
no test coverage detected