Separate resolved comments so they don't affect review panel

This commit is contained in:
James Allen 2017-01-13 15:27:45 +01:00
parent bf7038f506
commit b6ea338ff8
2 changed files with 15 additions and 3 deletions

View file

@ -1,7 +1,7 @@
#review-panel
.review-panel-toolbar
resolved-comments-dropdown(
entries="reviewPanel.entries"
entries="reviewPanel.resolvedComments"
threads="reviewPanel.commentThreads"
resolved-ids="reviewPanel.resolvedThreadIds"
docs="docs"

View file

@ -13,6 +13,7 @@ define [
$scope.reviewPanel =
entries: {}
resolvedComments: {}
hasEntries: false
subView: $scope.SubViews.CUR_FILE
openSubView: $scope.SubViews.CUR_FILE
@ -69,6 +70,10 @@ define [
$scope.reviewPanel.entries[doc_id] ?= {}
return $scope.reviewPanel.entries[doc_id]
getDocResolvedComments = (doc_id) ->
$scope.reviewPanel.resolvedComments[doc_id] ?= {}
return $scope.reviewPanel.resolvedComments[doc_id]
getChangeTracker = (doc_id) ->
if !rangesTrackers[doc_id]?
rangesTrackers[doc_id] = new RangesTracker()
@ -162,6 +167,7 @@ define [
updateEntries = (doc_id) ->
rangesTracker = getChangeTracker(doc_id)
entries = getDocEntries(doc_id)
resolvedComments = getDocResolvedComments(doc_id)
changed = false
@ -170,6 +176,8 @@ define [
for change_id, change of entries
if change_id != "add-comment"
delete_changes[change_id] = true
for change_id, change of resolvedComments
delete_changes[change_id] = true
for change in rangesTracker.changes
changed = true
@ -194,7 +202,10 @@ define [
for comment in rangesTracker.comments
changed = true
delete delete_changes[comment.id]
entries[comment.id] ?= {}
if $scope.reviewPanel.resolvedThreadIds[comment.op.t]
new_comment = resolvedComments[comment.id] ?= {}
else
new_comment = entries[comment.id] ?= {}
new_entry = {
type: "comment"
thread_id: comment.op.t
@ -202,11 +213,12 @@ define [
offset: comment.op.p
}
for key, value of new_entry
entries[comment.id][key] = value
new_comment[key] = value
for change_id, _ of delete_changes
changed = true
delete entries[change_id]
delete resolvedComments[change_id]
if changed
$scope.$broadcast "entries:changed"