mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Sort track changes and comments in overview mode (#21099)
GitOrigin-RevId: 795d30b56e57970363512170f504ab51bd104c93
This commit is contained in:
parent
332e2a38c9
commit
c606f04cce
1 changed files with 31 additions and 27 deletions
|
@ -3,9 +3,14 @@ import { MainDocument } from '../../../../../types/project-settings'
|
||||||
import { Ranges } from '../context/ranges-context'
|
import { Ranges } from '../context/ranges-context'
|
||||||
import { ReviewPanelComment } from './review-panel-comment'
|
import { ReviewPanelComment } from './review-panel-comment'
|
||||||
import { ReviewPanelChange } from './review-panel-change'
|
import { ReviewPanelChange } from './review-panel-change'
|
||||||
import { isDeleteChange, isInsertChange } from '@/utils/operations'
|
import {
|
||||||
|
isCommentOperation,
|
||||||
|
isDeleteChange,
|
||||||
|
isInsertChange,
|
||||||
|
} from '@/utils/operations'
|
||||||
import {
|
import {
|
||||||
Change,
|
Change,
|
||||||
|
CommentOperation,
|
||||||
DeleteOperation,
|
DeleteOperation,
|
||||||
EditOperation,
|
EditOperation,
|
||||||
} from '../../../../../types/change'
|
} from '../../../../../types/change'
|
||||||
|
@ -44,16 +49,15 @@ export const ReviewPanelOverviewFile: FC<{
|
||||||
return { aggregates, changes }
|
return { aggregates, changes }
|
||||||
}, [ranges])
|
}, [ranges])
|
||||||
|
|
||||||
const unresolvedComments = useMemo(() => {
|
const entries = useMemo(() => {
|
||||||
return ranges.comments.filter(comment => {
|
const unresolvedComments = ranges.comments.filter(comment => {
|
||||||
const thread = threads?.[comment.op.t]
|
const thread = threads?.[comment.op.t]
|
||||||
return thread && thread.messages.length > 0 && !thread.resolved
|
return thread && thread.messages.length > 0 && !thread.resolved
|
||||||
})
|
})
|
||||||
}, [ranges.comments, threads])
|
return [...changes, ...unresolvedComments].sort((a, b) => a.op.p - b.op.p)
|
||||||
|
}, [changes, ranges.comments, threads])
|
||||||
|
|
||||||
const numEntries = changes.length + unresolvedComments.length
|
if (entries.length === 0) {
|
||||||
|
|
||||||
if (numEntries === 0) {
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,31 +74,31 @@ export const ReviewPanelOverviewFile: FC<{
|
||||||
/>
|
/>
|
||||||
{doc.doc.name}
|
{doc.doc.name}
|
||||||
<div className="review-panel-overview-file-entry-count">
|
<div className="review-panel-overview-file-entry-count">
|
||||||
{numEntries}
|
{entries.length}
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{!collapsed && (
|
{!collapsed && (
|
||||||
<div className="review-panel-overview-file-entries">
|
<div className="review-panel-overview-file-entries">
|
||||||
{changes.map(change => (
|
{entries.map(entry =>
|
||||||
<ReviewPanelChange
|
isCommentOperation(entry.op) ? (
|
||||||
key={change.id}
|
<ReviewPanelComment
|
||||||
change={change}
|
key={entry.id}
|
||||||
aggregate={aggregates.get(change.id)}
|
comment={entry as Change<CommentOperation>}
|
||||||
editable={false}
|
docId={doc.doc.id}
|
||||||
docId={doc.doc.id}
|
hoverRanges={false}
|
||||||
hoverRanges={false}
|
/>
|
||||||
/>
|
) : (
|
||||||
))}
|
<ReviewPanelChange
|
||||||
|
key={entry.id}
|
||||||
{unresolvedComments.map(comment => (
|
change={entry as Change<EditOperation>}
|
||||||
<ReviewPanelComment
|
aggregate={aggregates.get(entry.id)}
|
||||||
key={comment.id}
|
editable={false}
|
||||||
comment={comment}
|
docId={doc.doc.id}
|
||||||
docId={doc.doc.id}
|
hoverRanges={false}
|
||||||
hoverRanges={false}
|
/>
|
||||||
/>
|
)
|
||||||
))}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue