Commit 17551718 authored by Randall Leeds's avatar Randall Leeds

Move reply pruning to threading plugin

parent dba43ab1
......@@ -312,17 +312,6 @@ annotation = [
'$document', 'annotator',
($document, annotator) ->
linkFn = (scope, elem, attrs, [ctrl, thread, threadFilter, counter]) ->
# Helper function to remove the temporary thread created for a new reply.
prune = (message) ->
return if message.id? # threading plugin will take care of it
return unless thread.container.message is message
thread.container.parent?.removeChild(thread.container)
if thread?
annotator.subscribe 'annotationDeleted', prune
scope.$on '$destroy', ->
annotator.unsubscribe 'annotationDeleted', prune
# Observe the embedded attribute
attrs.$observe 'annotationEmbedded', (value) ->
ctrl.embedded = value? and value != 'false'
......
......@@ -74,11 +74,18 @@ class Annotator.Plugin.Threading extends Annotator.Plugin
@idTable[annotation.id] = child
break
annotationDeleted: ({id}) =>
container = this.idTable[id]
if container?
annotationDeleted: (annotation) =>
if id of this.idTable
container = this.idTable[id]
container.message = null
delete this.idTable[id]
this.pruneEmpties(@root)
else
for id, container of this.idTable
for child in container.children when child.message is annotation
child.message = null
this.pruneEmpties(@root)
return
annotationsLoaded: (annotations) =>
messages = (@root.flattenChildren() or []).concat(annotations)
......
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