mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-18 21:07:44 +03:00
Remove duplicated call to split
This commit is contained in:
parent
07f815edfd
commit
7eb99d0b8d
@ -84,21 +84,20 @@ const AlbumComment = ({ record }) => {
|
|||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
const [expanded, setExpanded] = React.useState(false)
|
const [expanded, setExpanded] = React.useState(false)
|
||||||
|
|
||||||
|
const lines = record.comment.split('\n')
|
||||||
const formatted = useMemo(() => {
|
const formatted = useMemo(() => {
|
||||||
return record.comment.split('\n').map((line, idx) => (
|
return lines.map((line, idx) => (
|
||||||
<span key={record.id + '-comment-' + idx}>
|
<span key={record.id + '-comment-' + idx}>
|
||||||
<span dangerouslySetInnerHTML={{ __html: line }} />
|
<span dangerouslySetInnerHTML={{ __html: line }} />
|
||||||
<br />
|
<br />
|
||||||
</span>
|
</span>
|
||||||
))
|
))
|
||||||
}, [record.comment, record.id])
|
}, [lines, record.id])
|
||||||
|
|
||||||
const handleExpandClick = useCallback(() => {
|
const handleExpandClick = useCallback(() => {
|
||||||
setExpanded(!expanded)
|
setExpanded(!expanded)
|
||||||
}, [expanded, setExpanded])
|
}, [expanded, setExpanded])
|
||||||
|
|
||||||
const numLines = record.comment.split('\n').length
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Collapse
|
<Collapse
|
||||||
collapsedHeight={'1.5em'}
|
collapsedHeight={'1.5em'}
|
||||||
@ -106,7 +105,7 @@ const AlbumComment = ({ record }) => {
|
|||||||
timeout={'auto'}
|
timeout={'auto'}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
classes.commentBlock,
|
classes.commentBlock,
|
||||||
numLines > 1 && classes.pointerCursor
|
lines.length > 1 && classes.pointerCursor
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Typography variant={'body1'} onClick={handleExpandClick}>
|
<Typography variant={'body1'} onClick={handleExpandClick}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user