Skip to content

🎧 Your Personal Streaming Service

Remove duplicated call to `split`

Deluan7eb99d0b8d29
diff --git a/ui/src/album/AlbumDetails.js b/ui/src/album/AlbumDetails.js
index 724383b56..00671062e 100644
--- a/ui/src/album/AlbumDetails.js
+++ b/ui/src/album/AlbumDetails.js
@@ -84,21 +84,20 @@ const AlbumComment = ({ record }) => {
const classes = useStyles()
const [expanded, setExpanded] = React.useState(false)
+ const lines = record.comment.split('\n')
const formatted = useMemo(() => {
- return record.comment.split('\n').map((line, idx) => (
+ return lines.map((line, idx) => (
<span key={record.id + '-comment-' + idx}>
<span dangerouslySetInnerHTML={{ __html: line }} />
<br />
</span>
))
- }, [record.comment, record.id])
+ }, [lines, record.id])
const handleExpandClick = useCallback(() => {
setExpanded(!expanded)
}, [expanded, setExpanded])
- const numLines = record.comment.split('\n').length
-
return (
<Collapse
collapsedHeight={'1.5em'}
@@ -106,7 +105,7 @@ const AlbumComment = ({ record }) => {
timeout={'auto'}
className={clsx(
classes.commentBlock,
- numLines > 1 && classes.pointerCursor
+ lines.length > 1 && classes.pointerCursor
)}
>
<Typography variant={'body1'} onClick={handleExpandClick}>