mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Fix dirtyState handling in ranges context (#21724)
GitOrigin-RevId: 44f3aa9efc6dbd0d34a2b0440054197398a62caf
This commit is contained in:
parent
fe2ff49c72
commit
76c7c3e28e
1 changed files with 25 additions and 6 deletions
|
@ -43,13 +43,32 @@ const buildRanges = (currentDoc: DocumentContainer | null) => {
|
||||||
const dirtyState = ranges.getDirtyState()
|
const dirtyState = ranges.getDirtyState()
|
||||||
ranges.resetDirtyState()
|
ranges.resetDirtyState()
|
||||||
|
|
||||||
|
const changed = {
|
||||||
|
changes: new Set([
|
||||||
|
...Object.keys(dirtyState.change.added),
|
||||||
|
...Object.keys(dirtyState.change.moved),
|
||||||
|
...Object.keys(dirtyState.change.removed),
|
||||||
|
]),
|
||||||
|
comments: new Set([
|
||||||
|
...Object.keys(dirtyState.comment.added),
|
||||||
|
...Object.keys(dirtyState.comment.moved),
|
||||||
|
...Object.keys(dirtyState.comment.removed),
|
||||||
|
]),
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
changes: ranges.changes.map(change =>
|
changes:
|
||||||
change.id in dirtyState.change ? { ...change } : change
|
changed.changes.size > 0
|
||||||
),
|
? ranges.changes.map(change =>
|
||||||
comments: ranges.comments.map(comment =>
|
changed.changes.has(change.id) ? { ...change } : change
|
||||||
comment.id in dirtyState.comment ? { ...comment } : comment
|
)
|
||||||
),
|
: ranges.changes,
|
||||||
|
comments:
|
||||||
|
changed.comments.size > 0
|
||||||
|
? ranges.comments.map(comment =>
|
||||||
|
changed.comments.has(comment.id) ? { ...comment } : comment
|
||||||
|
)
|
||||||
|
: ranges.comments,
|
||||||
docId: currentDoc.doc_id,
|
docId: currentDoc.doc_id,
|
||||||
total: ranges.changes.length + ranges.comments.length,
|
total: ranges.changes.length + ranges.comments.length,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue