Commit 0f58e9b5 authored by Kristof Csillag's avatar Kristof Csillag

Merge pull request #545 from hypothesis/544-delete-breaks-displayer

Fixes #544
parents d0c826f7 9c0be2c7
......@@ -866,9 +866,10 @@ blockquote {
margin:0;
}
.center_button {
text-align: center;
.knockout {
.center {
text-align: center;
}
}
.button_controls {
......
......@@ -20,6 +20,9 @@ class Displayer
$scope.annotations = [$scope.annotation]
$scope.annotation.replies = []
$scope.annotation.reply_count = 0
$scope.annotation.ref_length =
if $scope.annotation.references? then $scope.annotation.references.length else 0
$scope.full_deleted = false
@idTable[$scope.annotation.id] = $scope.annotation
$scope.filter =
streamfilter
......@@ -62,7 +65,7 @@ class Displayer
#sort annotations by creation date
data.sort (a, b) ->
if a.created > b.created then return 1
if a.created > b.created then return -1
if a.created < b.created then return -1
0
for annotation in data
......@@ -102,17 +105,21 @@ class Displayer
unless @idTable[annotation.id]?
break
#Update the reply counter for all referenced annotation
for i in [$scope.annotation.ref_length..annotation.references.length-1]
reference = annotation.references[i]
@idTable[reference].reply_count -= 1
replies = @idTable[annotation.references[annotation.references.length-1]].replies
#Find the place to insert annotation
pos = replies.indexOf @idTable[annotation.id]
replies.splice pos, 1
delete @idTable[annotation.id]
if $scope.annotation.id is annotation.id
$scope.full_deleted = true
else
#Reply delete
#Update the reply counter for all referenced annotation
for i in [$scope.annotation.ref_length..annotation.references.length-1]
reference = annotation.references[i]
@idTable[reference].reply_count -= 1
replies = @idTable[annotation.references[annotation.references.length-1]].replies
#Find the place to insert annotation
pos = replies.indexOf @idTable[annotation.id]
replies.splice pos, 1
delete @idTable[annotation.id]
if $scope.annotation.referrers?
$scope.manage_new_data $scope.annotation.referrers, 'past'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment