Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 13x 31x 33x 33x 33x 33x 33x 33x 33x | import { Skeleton } from "@mui/material"; import makeStyles from "@mui/styles/makeStyles"; import classNames from "classnames"; import TextBody from "components/TextBody"; import { useLiteUser } from "features/userQueries/useLiteUsers"; import { useTranslation } from "i18n"; import { MESSAGES } from "i18n/namespaces"; import React from "react"; import { timestamp2Date } from "../../../utils/date"; import { firstName } from "../../../utils/names"; import useOnVisibleEffect from "../../../utils/useOnVisibleEffect"; import { controlMessage, messageTargetId } from "../utils"; import { messageElementId, MessageProps } from "./MessageView"; import TimeInterval from "./TimeInterval"; const useStyles = makeStyles((theme) => ({ message: { paddingInlineEnd: theme.spacing(1), }, root: { marginInlineEnd: "auto", marginInlineStart: "auto", textAlign: "center", }, skeleton: { minWidth: 100 }, timestamp: theme.typography.caption, })); export default function ControlMessageView({ message, onVisible, className, }: MessageProps) { const { t } = useTranslation(MESSAGES); const classes = useStyles(); const { data: author, isLoading: isAuthorLoading } = useLiteUser( message.authorUserId ); const { data: target, isLoading: isTargetLoading } = useLiteUser( messageTargetId(message) ); const { ref } = useOnVisibleEffect(onVisible); const authorName = firstName(author?.name); const targetName = firstName(target?.name); return ( <div className={classNames(classes.root, className)} data-testid={`message-${message.messageId}`} ref={ref} id={messageElementId(message.messageId)} > <div className={classes.timestamp}> <TimeInterval date={timestamp2Date(message.time!)} /> </div> <div className={classes.message}> {!isAuthorLoading && !isTargetLoading ? ( <TextBody> {controlMessage({ message, user: authorName, target_user: targetName, t, })} </TextBody> ) : ( <Skeleton className={classes.skeleton} /> )} </div> </div> ); } |