({
fDelete,
title,
date,
image,
priority,
content,
extras,
appName,
onExpand,
expanded: initialExpanded,
}: IProps)
| 115 | }; |
| 116 | |
| 117 | const Message = ({ |
| 118 | fDelete, |
| 119 | title, |
| 120 | date, |
| 121 | image, |
| 122 | priority, |
| 123 | content, |
| 124 | extras, |
| 125 | appName, |
| 126 | onExpand, |
| 127 | expanded: initialExpanded, |
| 128 | }: IProps) => { |
| 129 | const theme = useTheme(); |
| 130 | const contentRef = React.useRef<HTMLDivElement | null>(null); |
| 131 | const {classes} = useStyles(); |
| 132 | const [expanded, setExpanded] = React.useState(initialExpanded); |
| 133 | const [isOverflowing, setOverflowing] = React.useState(false); |
| 134 | const smallHeader = useMediaQuery(theme.breakpoints.down('md')); |
| 135 | |
| 136 | const refreshOverflowing = React.useCallback(() => { |
| 137 | const ref = contentRef.current; |
| 138 | if (!ref) { |
| 139 | return; |
| 140 | } |
| 141 | setOverflowing((overflowing) => overflowing || ref.scrollHeight > ref.clientHeight); |
| 142 | }, [contentRef, setOverflowing]); |
| 143 | |
| 144 | const onContentRef = React.useCallback( |
| 145 | (ref: HTMLDivElement | null) => { |
| 146 | contentRef.current = ref; |
| 147 | refreshOverflowing(); |
| 148 | }, |
| 149 | [contentRef, refreshOverflowing] |
| 150 | ); |
| 151 | |
| 152 | React.useEffect(() => void onExpand(expanded), [expanded]); |
| 153 | |
| 154 | const togglePreviewHeight = () => setExpanded((b) => !b); |
| 155 | |
| 156 | const renderContent = () => { |
| 157 | switch (contentType(extras)) { |
| 158 | case RenderMode.Markdown: |
| 159 | return <Markdown onImageLoaded={refreshOverflowing}>{content}</Markdown>; |
| 160 | case RenderMode.Plain: |
| 161 | default: |
| 162 | return <span className={classes.plainContent}>{content}</span>; |
| 163 | } |
| 164 | }; |
| 165 | return ( |
| 166 | <div className={`${classes.wrapperPadding} message`}> |
| 167 | <Container |
| 168 | style={{ |
| 169 | display: 'flex', |
| 170 | flexWrap: 'wrap', |
| 171 | borderLeftColor: priorityColor(priority), |
| 172 | borderLeftWidth: 6, |
| 173 | borderLeftStyle: 'solid', |
| 174 | }}> |
nothing calls this directly
no test coverage detected
searching dependent graphs…