Function
getPickSignal
({
upvoted,
bookmarked,
read,
post,
reason,
}: Omit<PickRowData, 'reason'> & { reason?: PickRowReason })
Source from the content-addressed store, hash-verified
| 19 | }; |
| 20 | |
| 21 | export const getPickSignal = ({ |
| 22 | upvoted, |
| 23 | bookmarked, |
| 24 | read, |
| 25 | post, |
| 26 | reason, |
| 27 | }: Omit<PickRowData, 'reason'> & { reason?: PickRowReason }): string => { |
| 28 | const parts: string[] = []; |
| 29 | if (upvoted) { |
| 30 | parts.push('▲ upvoted'); |
| 31 | } |
| 32 | if (bookmarked) { |
| 33 | parts.push('bookmarked'); |
| 34 | } |
| 35 | if (read && !upvoted && !bookmarked) { |
| 36 | parts.push('read'); |
| 37 | } |
| 38 | const fillLabel = reason && fillLabels[reason]; |
| 39 | if (fillLabel && !parts.length) { |
| 40 | parts.push(fillLabel); |
| 41 | } |
| 42 | if (post.readTime) { |
| 43 | parts.push(`${post.readTime} min`); |
| 44 | } |
| 45 | return parts.join(' · '); |
| 46 | }; |
| 47 | |
| 48 | interface PickRowProps { |
| 49 | row: PickRowData; |
Tested by
no test coverage detected