overleaf/services/web/frontend/js/features/review-panel-new/components/review-panel-comment.tsx
David 8685d87920 Merge pull request #20494 from overleaf/dp-zero-message-thread
Don't show comment threads with zero messages

GitOrigin-RevId: e9efdf4fc1119b8fdafdd8a93c7cd9caed91a276
2024-09-20 08:05:03 +00:00

36 lines
1.2 KiB
TypeScript

import { memo } from 'react'
import { Change, CommentOperation } from '../../../../../types/change'
import { useThreadsContext } from '../context/threads-context'
import classnames from 'classnames'
import { ReviewPanelEntry } from './review-panel-entry'
import MaterialIcon from '@/shared/components/material-icon'
import { ReviewPanelCommentContent } from './review-panel-comment-content'
export const ReviewPanelComment = memo<{
comment: Change<CommentOperation>
top?: number
}>(({ comment, top }) => {
const threads = useThreadsContext()
const thread = threads?.[comment.op.t]
if (!thread || thread.resolved || thread.messages.length === 0) {
return null
}
return (
<ReviewPanelEntry
className={classnames('review-panel-entry-comment', {
'review-panel-entry-loaded': !!threads?.[comment.op.t],
})}
top={top}
op={comment.op}
position={comment.op.p}
>
<div className="review-panel-entry-indicator">
<MaterialIcon type="edit" className="review-panel-entry-icon" />
</div>
<ReviewPanelCommentContent comment={comment} isResolved={false} />
</ReviewPanelEntry>
)
})
ReviewPanelComment.displayName = 'ReviewPanelComment'