({
isEnabled,
isStreakLoading,
state,
hasReadToday,
lastViewAt,
canSuggest = true,
}: UsePatchyRailProps)
| 26 | // (his face, idle animations and reactions in the circle) and the assistant |
| 27 | // (suggestions). |
| 28 | export 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 | }; |
no test coverage detected