Commit d0795706 authored by Aron Carroll's avatar Aron Carroll

Remove redundant code from loadAnnotations

The current implementation assumed that the setupAnnotation method
needed to do a large amount of work and so batched the calls. Our
sidebar no-ops this method so we can effectively get rid of the
setup method and batch calls.
parent 6d0d4426
...@@ -15,7 +15,7 @@ class AnnotationMapperService ...@@ -15,7 +15,7 @@ class AnnotationMapperService
annotation annotation
annotations = (new store.AnnotationResource(a) for a in annotations) annotations = (new store.AnnotationResource(a) for a in annotations)
setupAndLoadAnnotations(annotations) $rootScope.$emit('annotationsLoaded', annotations)
this.createAnnotation = (annotation) -> this.createAnnotation = (annotation) ->
annotation = new store.AnnotationResource(annotation) annotation = new store.AnnotationResource(annotation)
...@@ -27,26 +27,4 @@ class AnnotationMapperService ...@@ -27,26 +27,4 @@ class AnnotationMapperService
$rootScope.$emit('annotationDeleted', annotation) $rootScope.$emit('annotationDeleted', annotation)
annotation annotation
# From Annotator core.
setupAndLoadAnnotations = (annotations) =>
clone = annotations.slice()
loader = (annList=[]) =>
now = annList.splice(0,10)
for n in now
this.setupAnnotation(n)
# If there are more to do, do them after a 10ms break (for browser
# responsiveness).
if annList.length > 0
setTimeout((-> loader(annList)), 10)
else
$rootScope.$emit('annotationsLoaded', clone)
if annotations.length # Do we have to do something?
setTimeout -> loader(annotations)
else # no pending scan
# We can start parsing them right away
loader(annotations)
angular.module('h').service('annotationMapper', AnnotationMapperService) angular.module('h').service('annotationMapper', AnnotationMapperService)
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