import { useAttachment } from "@/app/providers/AttachmentProvider/useAttachment"; import { AttachmentProps } from "./MessageAttachments"; import { Avatar, Box, Flex, Text } from "@mantine/core"; import { useRosettaColors } from "@/app/hooks/useRosettaColors"; import { IconPhoneOutgoing, IconX } from "@tabler/icons-react"; import { translateDurationToTime } from "@/app/providers/CallProvider/translateDurationTime"; import { usePublicKey } from "@/app/providers/AccountProvider/usePublicKey"; export function MessageCall(props: AttachmentProps) { const { getPreview, } = useAttachment( props.attachment, props.parent, ); const publicKey = usePublicKey(); const preview = getPreview(); const caller = props.parent.from == publicKey; const duration = parseInt(preview); const colors = useRosettaColors(); const error = duration == 0; return ( {!error && <> {!caller && ( )} {caller && ( )} } {error && <> } { error ? (!caller ? "Missed call" : "Rejected call") : (!caller ? "Incoming call" : "Outgoing call") } {!error && {translateDurationToTime(duration)} } {error && Call was not answered or was rejected } ); }