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

Function getPatchyMood

packages/shared/src/features/patchy/patchyTriggers.ts:81–101  ·  view source on GitHub ↗
({
  state,
  hasReadToday,
  lastViewAt,
  now,
  config,
}: PatchyMoodInput)

Source from the content-addressed store, hash-verified

79
80// Never sad, never guilt: the worst he gets is asleep.
81export 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.

Callers 2

usePatchyCompanionFunction · 0.90

Calls 2

isAwayFunction · 0.85
isLateNightFunction · 0.85

Tested by

no test coverage detected