()
| 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', |
| 151 | label: `Best of #${tag}`, |
| 152 | icon: icon.trending, |
| 153 | href: `${webappUrl}tags/${encodeURIComponent(tag)}/best-of`, |
| 154 | }); |
| 155 | |
| 156 | switch (context.kind) { |
| 157 | case 'post': { |
| 158 | const { post, tag } = context; |
| 159 | const list: MenuItem[] = []; |
| 160 | if (!post.bookmarked || done.includes('save')) { |
| 161 | list.push({ |
| 162 | id: 'save', |
| 163 | label: done.includes('save') ? 'Saved for later' : 'Save for later', |
| 164 | icon: icon.bookmark, |
| 165 | isDone: done.includes('save'), |
| 166 | onClick: () => { |
| 167 | const latest = getPatchyCurrentPost(client, post); |
| 168 | if (!latest.bookmarked) { |
| 169 | toggleBookmark({ post: latest as Post, origin: Origin.Patchy }); |
| 170 | } |
| 171 | setDone((current) => [...current, 'save']); |
| 172 | }, |
| 173 | }); |
| 174 | } |
| 175 | if (tag && (!isFollowing(tag) || done.includes('follow'))) { |
no test coverage detected