2024-08-19 09:16:56 -04:00
|
|
|
import { memo } from 'react'
|
2024-08-12 05:50:54 -04:00
|
|
|
import { Change, CommentOperation } from '../../../../../types/change'
|
2024-08-19 09:16:56 -04:00
|
|
|
import { useThreadsContext } from '../context/threads-context'
|
2024-08-12 05:50:54 -04:00
|
|
|
import classnames from 'classnames'
|
2024-08-15 06:07:40 -04:00
|
|
|
import { ReviewPanelEntry } from './review-panel-entry'
|
2024-08-19 09:16:56 -04:00
|
|
|
import MaterialIcon from '@/shared/components/material-icon'
|
|
|
|
import { ReviewPanelCommentContent } from './review-panel-comment-content'
|
2024-08-12 05:50:54 -04:00
|
|
|
|
|
|
|
export const ReviewPanelComment = memo<{
|
|
|
|
comment: Change<CommentOperation>
|
|
|
|
top?: number
|
|
|
|
}>(({ comment, top }) => {
|
|
|
|
const threads = useThreadsContext()
|
|
|
|
|
|
|
|
const thread = threads?.[comment.op.t]
|
2024-09-19 06:07:43 -04:00
|
|
|
if (!thread || thread.resolved || thread.messages.length === 0) {
|
2024-08-12 05:50:54 -04:00
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2024-08-15 06:07:40 -04:00
|
|
|
<ReviewPanelEntry
|
|
|
|
className={classnames('review-panel-entry-comment', {
|
|
|
|
'review-panel-entry-loaded': !!threads?.[comment.op.t],
|
|
|
|
})}
|
|
|
|
top={top}
|
|
|
|
op={comment.op}
|
|
|
|
position={comment.op.p}
|
2024-08-12 05:50:54 -04:00
|
|
|
>
|
|
|
|
<div className="review-panel-entry-indicator">
|
2024-09-24 04:54:22 -04:00
|
|
|
<MaterialIcon type="comment" className="review-panel-entry-icon" />
|
2024-08-12 05:50:54 -04:00
|
|
|
</div>
|
2024-08-19 09:16:56 -04:00
|
|
|
<ReviewPanelCommentContent comment={comment} isResolved={false} />
|
2024-08-15 06:07:40 -04:00
|
|
|
</ReviewPanelEntry>
|
2024-08-12 05:50:54 -04:00
|
|
|
)
|
|
|
|
})
|
|
|
|
ReviewPanelComment.displayName = 'ReviewPanelComment'
|