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

Function usePatchyRail

packages/shared/src/features/patchy/usePatchyRail.ts:28–72  ·  view source on GitHub ↗
({
  isEnabled,
  isStreakLoading,
  state,
  hasReadToday,
  lastViewAt,
  canSuggest = true,
}: UsePatchyRailProps)

Source from the content-addressed store, hash-verified

26// (his face, idle animations and reactions in the circle) and the assistant
27// (suggestions).
28export const usePatchyRail = ({
29 isEnabled,
30 isStreakLoading,
31 state,
32 hasReadToday,
33 lastViewAt,
34 canSuggest = true,
35}: UsePatchyRailProps) => {
36 const { logEvent } = useLogContext();
37 const { displayToast } = useToastNotification();
38 const { isReactionsEnabled } = usePatchyReactions();
39 const { isSuggestionsEnabled, setSuggestionsEnabled } =
40 usePatchySuggestions();
41 const assistant = usePatchyAssistant({
42 isEnabled: isEnabled && canSuggest && isSuggestionsEnabled,
43 isStreakLoading,
44 state,
45 hasReadToday,
46 lastViewAt,
47 });
48 const isReading = usePatchyReading(isEnabled);
49 const companion = usePatchyCompanion({
50 isEnabled,
51 isReactionsEnabled,
52 isStreakLoading,
53 state,
54 hasReadToday,
55 lastViewAt,
56 isReading,
57 offerFace: assistant.offer ? offerFace : null,
58 });
59
60 // Quiet mode: no more suggestions; he keeps living in his circle.
61 const onQuiet = useCallback(() => {
62 setSuggestionsEnabled(false);
63 displayToast('Quiet mode on. Patchy will just hang out in his circle.');
64 logEvent({
65 event_name: LogEvent.ChangeSettings,
66 target_type: TargetType.PatchySuggestions,
67 target_id: 'quiet',
68 });
69 }, [setSuggestionsEnabled, displayToast, logEvent]);
70
71 return { ...companion, isReading, assistant, onQuiet };
72};

Callers 3

SidebarDesktopV2Function · 0.90
PatchyPhoneBrainFunction · 0.90
OwnPatchyHeaderIconFunction · 0.90

Calls 9

useLogContextFunction · 0.90
useToastNotificationFunction · 0.90
usePatchyReactionsFunction · 0.90
usePatchySuggestionsFunction · 0.90
usePatchyAssistantFunction · 0.90
usePatchyReadingFunction · 0.90
usePatchyCompanionFunction · 0.90
displayToastFunction · 0.85
logEventFunction · 0.85

Tested by

no test coverage detected