import { Button, HStack, Icon, Popover, PopoverArrow, PopoverBody, PopoverContent, PopoverTrigger, Text, TextProps, } from "@chakra-ui/react"; import { PublicKey } from "@solana/web3.js"; import { truncatePubkey, useErrorHandler } from "@strata-foundation/react"; import React from "react"; import { MdOutlineAddReaction } from "react-icons/md"; import { IMessageWithPending } from "../../hooks/useMessages"; import { useInflatedReacts } from "../../hooks/useInflatedReacts"; import { useWalletProfile } from "../../hooks/useWalletProfile"; import { useUsernameFromIdentifierCertificate } from "../../hooks/useUsernameFromIdentifierCertificate"; const MAX_MENTIONS_DISPLAY = 3; function ProfileName({ sender }: { sender: PublicKey } & TextProps) { const { info: profile } = useWalletProfile(sender); const { username } = useUsernameFromIdentifierCertificate( profile?.identifierCertificateMint, sender ); const name = username || (sender && truncatePubkey(sender)); return {name} ; } export function Reacts({ reacts, onReact, onAddReaction, }: { reacts: IMessageWithPending[]; onReact: (emoji: string, mint: boolean) => void; onAddReaction: () => void; }) { const { reacts: inflatedReacts, error: reactError, loading: reactsLoading, } = useInflatedReacts(reacts); const { handleErrors } = useErrorHandler(); handleErrors(reactError); if (inflatedReacts && inflatedReacts.length > 0) { return ( {inflatedReacts.map(({ emoji, messages, mine }) => ( {/* @ts-ignore */} {messages .slice(0, MAX_MENTIONS_DISPLAY) .map((message, index) => ( {messages.length - 1 != index && , } ))} {messages.length > MAX_MENTIONS_DISPLAY && ( and {messages.length - MAX_MENTIONS_DISPLAY} others )} ))} ); } return
; }