({
date,
post,
className,
onClose,
onReadArticle,
showActions = true,
hideSubscribeAction,
}: SourceInfoProps)
| 37 | } |
| 38 | |
| 39 | function PostSourceInfo({ |
| 40 | date, |
| 41 | post, |
| 42 | className, |
| 43 | onClose, |
| 44 | onReadArticle, |
| 45 | showActions = true, |
| 46 | hideSubscribeAction, |
| 47 | }: SourceInfoProps): ReactElement { |
| 48 | const { source } = post; |
| 49 | const sourceId = source?.id ?? ''; |
| 50 | const sourceHandle = source?.handle ?? ''; |
| 51 | const sourceName = source?.name ?? ''; |
| 52 | const sourcePermalink = source?.permalink ?? ''; |
| 53 | const { showActionBtn } = useShowFollowAction({ |
| 54 | entityId: sourceId, |
| 55 | entityType: ContentPreferenceType.Source, |
| 56 | }); |
| 57 | const isUnknown = sourceId === 'unknown'; |
| 58 | const { squad, isLoading: isLoadingSquad } = useSquad({ |
| 59 | handle: sourceHandle, |
| 60 | }); |
| 61 | const { data } = useContentPreferenceStatusQuery({ |
| 62 | id: sourceId, |
| 63 | entity: ContentPreferenceType.Source, |
| 64 | }); |
| 65 | const isUserSource = isSourceUserSource(post?.source); |
| 66 | const contentPreferenceStatus = data?.status; |
| 67 | |
| 68 | const isFollowing = |
| 69 | contentPreferenceStatus === ContentPreferenceStatus.Follow || |
| 70 | contentPreferenceStatus === ContentPreferenceStatus.Subscribed; |
| 71 | |
| 72 | return ( |
| 73 | <span |
| 74 | className={classNames( |
| 75 | 'flex flex-row items-center text-text-tertiary typo-footnote', |
| 76 | className, |
| 77 | )} |
| 78 | > |
| 79 | {!isUnknown && ( |
| 80 | <div className="flex flex-row items-center"> |
| 81 | {!isUserSource && ( |
| 82 | <Link href={sourcePermalink}> |
| 83 | <a className="text-text-secondary typo-callout"> |
| 84 | {sourceName || sourceHandle} |
| 85 | </a> |
| 86 | </Link> |
| 87 | )} |
| 88 | {showsVerifiedBadge(source) && ( |
| 89 | <VerifiedSquadBadge className="ml-1 size-4" /> |
| 90 | )} |
| 91 | {showActionBtn && ( |
| 92 | <> |
| 93 | {!isUserSource && <Separator className="flex tablet:hidden" />} |
| 94 | {source?.type !== SourceType.Squad && !isUserSource && ( |
| 95 | <FollowButton |
| 96 | variant={ButtonVariant.Tertiary} |
nothing calls this directly
no test coverage detected