Commit 82d25138 authored by Sean Hammond's avatar Sean Hammond

Make loadAnnotations accept separate annotations and replies arrays

Do the concatenating of these loadAnnotations() instead of in multiple
places that call it.
parent 1b4a6bae
......@@ -19,7 +19,9 @@ function getContainer(threading, annotation) {
// Wraps the annotation store to trigger events for the CRUD actions
// @ngInject
function annotationMapper($rootScope, threading, store) {
function loadAnnotations(annotations) {
function loadAnnotations(annotations, replies) {
annotations = annotations.concat(replies || []);
var loaded = [];
annotations.forEach(function (annotation) {
......
......@@ -23,7 +23,7 @@ module.exports = class AnnotationViewerController
$location.path('/stream').search('q', query)
store.SearchResource.get _id: id, ({rows, replies}) ->
annotationMapper.loadAnnotations(rows.concat(replies))
annotationMapper.loadAnnotations(rows, replies)
$scope.threadRoot = {children: [threading.idTable[id]]}
streamFilter
......
......@@ -23,7 +23,7 @@ module.exports = class StreamController
load = ({rows, replies}) ->
offset += rows.length
annotationMapper.loadAnnotations(rows.concat(replies))
annotationMapper.loadAnnotations(rows, replies)
# Disable the thread filter (client-side search)
$scope.$on '$routeChangeSuccess', ->
......
......@@ -71,5 +71,5 @@ describe "AnnotationViewerController", ->
})
assert annotationMapper.loadAnnotations.calledWith(
['annotation_1', 'annotation_2', 'reply_1', 'reply_2', 'reply_3']
['annotation_1', 'annotation_2'], ['reply_1', 'reply_2', 'reply_3']
), "It should pass all the annotations and replies to loadAnnotations()"
......@@ -97,7 +97,7 @@ describe 'StreamController', ->
assert fakeAnnotationMapper.loadAnnotations.calledOnce
assert fakeAnnotationMapper.loadAnnotations.calledWith(
['annotation_1', 'annotation_2', 'reply_1', 'reply_2', 'reply_3']
['annotation_1', 'annotation_2'], ['reply_1', 'reply_2', 'reply_3']
)
......
......@@ -115,7 +115,7 @@ describe 'WidgetController', ->
assert fakeAnnotationMapper.loadAnnotations.calledOnce
assert fakeAnnotationMapper.loadAnnotations.calledWith(
['annotation_1', 'annotation_2', 'reply_1', 'reply_2', 'reply_3']
['annotation_1', 'annotation_2'], ['reply_1', 'reply_2', 'reply_3']
)
describe 'when the focused group changes', ->
......
......@@ -39,7 +39,7 @@ module.exports = class WidgetController
if offset < total
_loadAnnotationsFrom query, offset
annotationMapper.loadAnnotations(results.rows.concat(results.replies))
annotationMapper.loadAnnotations(results.rows, results.replies)
loadAnnotations = (frames) ->
for f in frames
......
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