Commit a7c78ac6 authored by Gergely Ujvari's avatar Gergely Ujvari

Load all annotations incrementally

Instead of just one search call (with a fix limit),
process the total field from the result of the first
load and while there is still more to load, initiate
a new search query, with the offset property set to
load the remaining ones
parent 82fbab54
......@@ -187,8 +187,19 @@ class ViewerController
loaded = []
_loadAnnotationsFrom = (query, offset) ->
q = angular.extend({limit: 20, offset: offset}, query)
store.SearchResource.get q, (results) ->
total = results.total
offset += results.rows.length
if offset < total
_loadAnnotationsFrom query, offset
annotationMapper.loadAnnotations(results.rows)
loadAnnotations = ->
query = limit: 200
query = {}
if annotationUI.tool is 'highlight'
return unless auth.user
query.user = auth.user
......@@ -196,8 +207,8 @@ class ViewerController
for p in crossframe.providers
for e in p.entities when e not in loaded
loaded.push e
r = store.SearchResource.get angular.extend(uri: e, query), (results) ->
annotationMapper.loadAnnotations(results.rows)
q = angular.extend(uri: e, query)
_loadAnnotationsFrom q, 0
streamfilter.resetFilter().addClause('/uri', 'one_of', loaded)
......
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