"use client"; import { useContext, useState } from "react"; import { Separator } from "./Layout"; import { CommentTiny } from "./Icons/CommentTiny"; import { useSmoker } from "./Toast"; import { Tag } from "./Tags"; import { Popover } from "./Popover"; import { TagTiny } from "./Icons/TagTiny"; import { RecommendButton } from "./RecommendButton"; import { DiscussionModal } from "./DiscussionModal"; import { DrawerThreadContext } from "app/(app)/lish/[did]/[publication]/[rkey]/Interactions/drawerThreadContext"; export const InteractionPreview = (props: { quotesCount: number; commentsCount: number; recommendsCount: number; documentUri: string; tags?: string[]; postUrl: string; title?: string; showComments: boolean; showMentions: boolean; showRecommends: boolean; share?: boolean; }) => { let smoker = useSmoker(); // Inside a published post body a DrawerThreadContext is in scope; there we // open this post's discussion in the interaction drawer (like a Bluesky post's // thread) instead of the standalone modal used in listings/feeds. let drawerNav = useContext(DrawerThreadContext); let [discussionsOpen, setDiscussionsOpen] = useState(false); let commentsAvailable = props.showComments !== false && props.commentsCount > 0; let mentionsAvailable = props.showMentions && props.quotesCount > 0; let discussionsAvailable = commentsAvailable || mentionsAvailable; let interactionsAvailable = discussionsAvailable || (props.showRecommends !== false && props.recommendsCount > 0); const tagsCount = props.tags?.length || 0; return (
{props.showRecommends === false ? null : ( )} {!discussionsAvailable ? null : ( )} {discussionsAvailable && !drawerNav && ( )} {tagsCount === 0 ? null : ( <> {interactionsAvailable ? : null} )} {props.share && ( <> )}
); }; export const TagPopover = (props: { tags: string[] }) => { return ( {props.tags.length} } > ); }; const TagList = (props: { tags: string[]; className?: string }) => { return (
{props.tags.map((tag, index) => ( ))}
); };