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

Function PatchyMenu

packages/shared/src/features/patchy/PatchyMenu.tsx:93–436  ·  view source on GitHub ↗
({
  context,
  onNavigate,
}: {
  context: PatchyContext;
  onNavigate?: () => void;
})

Source from the content-addressed store, hash-verified

91// search each get a few things that make sense there; anywhere else he
92// offers something to read, what's trending and search.
93export const PatchyMenu = ({
94 context,
95 onNavigate,
96}: {
97 context: PatchyContext;
98 onNavigate?: () => void;
99}): ReactElement => {
100 const client = useQueryClient();
101 const { logEvent } = useLogContext();
102 const spotlight = useContext(SpotlightContext);
103 const { feedSettings } = useFeedSettings();
104 const { onFollowTags } = useTagAndSource({ origin: Origin.Patchy });
105 const { toggleBookmark } = useBookmarkPost();
106 const openTune = useOpenFeedTune(Origin.Patchy);
107 const setExplain = useSetFeedExplain(Origin.Patchy);
108 const [picks, setPicks] = useState<{
109 kind: PicksKind;
110 posts: PatchyQuickRead[];
111 } | null>(null);
112 const [done, setDone] = useState<string[]>([]);
113
114 const followed = feedSettings?.includeTags ?? [];
115 const isFollowing = (tag: string) =>
116 followed.some((value) => value.toLowerCase() === tag.toLowerCase());
117
118 const getItems = (): MenuItem[] => {
119 const read: MenuItem = {
120 id: 'read',
121 label: 'What to read?',
122 icon: icon.read,
123 picks: 'feed',
124 };
125 const trending: MenuItem = {
126 id: 'trending',
127 label: 'What’s trending?',
128 icon: icon.trending,
129 href: `${webappUrl}highlights`,
130 };
131 const search: MenuItem = {
132 id: 'search',
133 label: 'Search daily.dev',
134 icon: icon.search,
135 onClick: spotlight?.open,
136 };
137 const followTag = (tag: string): MenuItem => ({
138 id: 'follow',
139 label: done.includes('follow') ? `Following #${tag}` : `Follow #${tag}`,
140 icon: icon.tag,
141 isDone: done.includes('follow'),
142 onClick: () =>
143 onFollowTags({ tags: [tag] }).then(({ successful }) => {
144 if (successful) {
145 setDone((current) => [...current, 'follow']);
146 }
147 }),
148 });
149 const bestOfTag = (tag: string): MenuItem => ({
150 id: 'best_of',

Callers

nothing calls this directly

Calls 11

useLogContextFunction · 0.90
useBookmarkPostFunction · 0.90
useOpenFeedTuneFunction · 0.90
useSetFeedExplainFunction · 0.90
openPatchyPostFunction · 0.90
useFeedSettingsFunction · 0.85
useTagAndSourceFunction · 0.85
togglePicksFunction · 0.85
getItemsFunction · 0.70
logFunction · 0.70
onNavigateFunction · 0.50

Tested by

no test coverage detected