Properly sync resolved comments dropdown to entries

This commit is contained in:
James Allen 2017-01-11 14:13:49 +01:00
parent 4ee4aa9f0a
commit a081ae7307
2 changed files with 10 additions and 3 deletions

View file

@ -130,7 +130,7 @@ define [
rangesTracker = getChangeTracker(doc.id) rangesTracker = getChangeTracker(doc.id)
rangesTracker.comments = doc.ranges?.comments or [] rangesTracker.comments = doc.ranges?.comments or []
rangesTracker.changes = doc.ranges?.changes or [] rangesTracker.changes = doc.ranges?.changes or []
updateEntries(doc.id) updateEntries(doc.id)
refreshOverviewPanel = () -> refreshOverviewPanel = () ->
$scope.reviewPanel.overview.loading = true $scope.reviewPanel.overview.loading = true
@ -152,6 +152,8 @@ define [
rangesTracker = getChangeTracker(doc_id) rangesTracker = getChangeTracker(doc_id)
entries = getDocEntries(doc_id) entries = getDocEntries(doc_id)
changed = false
# Assume we'll delete everything until we see it, then we'll remove it from this object # Assume we'll delete everything until we see it, then we'll remove it from this object
delete_changes = {} delete_changes = {}
for change_id, change of entries for change_id, change of entries
@ -159,6 +161,7 @@ define [
delete_changes[change_id] = true delete_changes[change_id] = true
for change in rangesTracker.changes for change in rangesTracker.changes
changed = true
delete delete_changes[change.id] delete delete_changes[change.id]
entries[change.id] ?= {} entries[change.id] ?= {}
@ -178,6 +181,7 @@ define [
refreshChangeUsers(change.metadata.user_id) refreshChangeUsers(change.metadata.user_id)
for comment in rangesTracker.comments for comment in rangesTracker.comments
changed = true
delete delete_changes[comment.id] delete delete_changes[comment.id]
entries[comment.id] ?= {} entries[comment.id] ?= {}
new_entry = { new_entry = {
@ -190,8 +194,12 @@ define [
entries[comment.id][key] = value entries[comment.id][key] = value
for change_id, _ of delete_changes for change_id, _ of delete_changes
changed = true
delete entries[change_id] delete entries[change_id]
if changed
$scope.$broadcast "entries:changed"
$scope.$on "editor:track-changes:changed", () -> $scope.$on "editor:track-changes:changed", () ->
doc_id = $scope.editor.open_doc_id doc_id = $scope.editor.open_doc_id
updateEntries(doc_id) updateEntries(doc_id)

View file

@ -21,7 +21,6 @@ define [
scope.toggleOpenState = () -> scope.toggleOpenState = () ->
scope.state.isOpen = !scope.state.isOpen scope.state.isOpen = !scope.state.isOpen
if (scope.state.isOpen) if (scope.state.isOpen)
filterResolvedComments()
scope.onOpen() scope.onOpen()
scope.resolvedComments = [] scope.resolvedComments = []
@ -55,4 +54,4 @@ define [
scope.resolvedComments.push(resolvedComment) scope.resolvedComments.push(resolvedComment)
scope.$watchCollection "resolvedIds", filterResolvedComments scope.$on "entries:changed", filterResolvedComments