Commit 0b182df8 authored by Randall Leeds's avatar Randall Leeds

Rewrite search pagination to use regular search

Replace the use of the websocket for scrollback with a simple
pagination scheme.
parent 3d3eacfa
...@@ -13,6 +13,18 @@ module.exports = class StreamController ...@@ -13,6 +13,18 @@ module.exports = class StreamController
queryParser, searchFilter, store, queryParser, searchFilter, store,
streamer, streamFilter, threading, annotationMapper streamer, streamFilter, threading, annotationMapper
) -> ) ->
offset = 0
fetch = (limit) ->
options = {offset, limit}
searchParams = searchFilter.toObject($routeParams.q)
query = angular.extend(options, searchParams)
store.SearchResource.get(query, load)
load = ({rows}) ->
offset += rows.length
annotationMapper.loadAnnotations(rows)
# Disable the thread filter (client-side search) # Disable the thread filter (client-side search)
$scope.$on '$routeChangeSuccess', -> $scope.$on '$routeChangeSuccess', ->
if $scope.threadFilter? if $scope.threadFilter?
...@@ -39,11 +51,8 @@ module.exports = class StreamController ...@@ -39,11 +51,8 @@ module.exports = class StreamController
queryParser.populateFilter streamFilter, terms queryParser.populateFilter streamFilter, terms
streamer.send({filter: streamFilter.getFilter()}) streamer.send({filter: streamFilter.getFilter()})
# Perform the search # Perform the initial search
searchParams = searchFilter.toObject $routeParams.q fetch(20)
query = angular.extend limit: 20, searchParams
store.SearchResource.get query, ({rows}) ->
annotationMapper.loadAnnotations(rows)
$scope.isEmbedded = false $scope.isEmbedded = false
$scope.isStream = true $scope.isStream = true
...@@ -52,5 +61,4 @@ module.exports = class StreamController ...@@ -52,5 +61,4 @@ module.exports = class StreamController
$scope.shouldShowThread = (container) -> true $scope.shouldShowThread = (container) -> true
$scope.loadMore = (number) -> $scope.loadMore = fetch
streamer.send({messageType: 'more_hits', moreHits: number})
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<ul class="stream-list" <ul class="stream-list"
deep-count="count" deep-count="count"
thread-filter="search.query" thread-filter="search.query"
window-scroll="loadMore(10)"> window-scroll="loadMore(20)">
<li ng-show="threadFilter.active()" <li ng-show="threadFilter.active()"
><span ng-pluralize ><span ng-pluralize
count="count('match')" count="count('match')"
......
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