Commit 17551718 authored by Randall Leeds's avatar Randall Leeds

Move reply pruning to threading plugin

parent dba43ab1
...@@ -312,17 +312,6 @@ annotation = [ ...@@ -312,17 +312,6 @@ annotation = [
'$document', 'annotator', '$document', 'annotator',
($document, annotator) -> ($document, annotator) ->
linkFn = (scope, elem, attrs, [ctrl, thread, threadFilter, counter]) -> 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 # Observe the embedded attribute
attrs.$observe 'annotationEmbedded', (value) -> attrs.$observe 'annotationEmbedded', (value) ->
ctrl.embedded = value? and value != 'false' ctrl.embedded = value? and value != 'false'
......
...@@ -74,11 +74,18 @@ class Annotator.Plugin.Threading extends Annotator.Plugin ...@@ -74,11 +74,18 @@ class Annotator.Plugin.Threading extends Annotator.Plugin
@idTable[annotation.id] = child @idTable[annotation.id] = child
break break
annotationDeleted: ({id}) => annotationDeleted: (annotation) =>
container = this.idTable[id] if id of this.idTable
if container? container = this.idTable[id]
container.message = null container.message = null
delete this.idTable[id]
this.pruneEmpties(@root) 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) => annotationsLoaded: (annotations) =>
messages = (@root.flattenChildren() or []).concat(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