Hey is a decentralized and permissionless social media app built with Lens Protocol 馃尶
at main 44 lines 1.7 kB view raw
1import { isRepost } from "@hey/helpers/postHelpers"; 2import type { AnyPostFragment } from "@hey/indexer"; 3import { memo } from "react"; 4import CollectAction from "@/components/Post/OpenAction/CollectAction"; 5import SmallCollectButton from "@/components/Post/OpenAction/CollectAction/SmallCollectButton"; 6import TipAction from "@/components/Post/OpenAction/TipAction"; 7import stopEventPropagation from "@/helpers/stopEventPropagation"; 8import Comment from "./Comment"; 9import Like from "./Like"; 10import ShareMenu from "./Share"; 11 12interface PostActionsProps { 13 post: AnyPostFragment; 14 showCount?: boolean; 15} 16 17const PostActions = ({ post, showCount = false }: PostActionsProps) => { 18 const targetPost = isRepost(post) ? post.repostOf : post; 19 const hasPostAction = (targetPost.actions?.length || 0) > 0; 20 const tipEnabled = targetPost.author?.hasSubscribed; 21 const canAct = 22 hasPostAction && 23 targetPost.actions.some( 24 (action) => action.__typename === "SimpleCollectAction" 25 ); 26 27 return ( 28 <span 29 className="mt-3 flex w-full flex-wrap items-center justify-between gap-3" 30 onClick={stopEventPropagation} 31 > 32 <span className="flex items-center gap-x-6"> 33 <Comment post={targetPost} showCount={showCount} /> 34 <ShareMenu post={post} showCount={showCount} /> 35 <Like post={targetPost} showCount={showCount} /> 36 {canAct && !showCount ? <CollectAction post={targetPost} /> : null} 37 {tipEnabled && <TipAction post={targetPost} showCount={showCount} />} 38 </span> 39 {canAct ? <SmallCollectButton post={targetPost} /> : null} 40 </span> 41 ); 42}; 43 44export default memo(PostActions);