Skip to content

Instantly share code, notes, and snippets.

@tilgovi
Created April 17, 2015 20:31
Show Gist options
  • Save tilgovi/b9dba63855a4f4a79f1f to your computer and use it in GitHub Desktop.
Save tilgovi/b9dba63855a4f4a79f1f to your computer and use it in GitHub Desktop.
Disable the page search on stream results
diff --git a/h/static/scripts/stream-controller.coffee b/h/static/scripts/stream-controller.coffee
index 1a275a1..ccb4575 100644
--- a/h/static/scripts/stream-controller.coffee
+++ b/h/static/scripts/stream-controller.coffee
@@ -5,26 +5,32 @@ module.exports = class StreamController
this.inject = [
'$scope', '$rootScope', '$routeParams',
'auth', 'queryParser', 'searchFilter', 'store',
- 'streamer', 'streamFilter', 'annotationMapper'
+ 'streamer', 'streamFilter', 'threading', 'annotationMapper'
]
constructor: (
$scope, $rootScope, $routeParams
auth, queryParser, searchFilter, store,
- streamer, streamFilter, annotationMapper
+ streamer, streamFilter, threading, annotationMapper
) ->
+ # XXX: Clear out any old annotations
+ while threading.root.children.length
+ threading.root.removeChild(threading.root.children[0])
+ for id of threading.idTable
+ delete threading.idTable[id]
+
# Initialize the base filter
streamFilter
.resetFilter()
.setMatchPolicyIncludeAll()
# Apply query clauses
- $scope.search.query = $routeParams.q
- terms = searchFilter.generateFacetedFilter $scope.search.query
+ $scope.search = {} # XXX: disable page search
+ terms = searchFilter.generateFacetedFilter $routeParams.q
queryParser.populateFilter streamFilter, terms
streamer.send({filter: streamFilter.getFilter()})
# Perform the search
- searchParams = searchFilter.toObject $scope.search.query
+ searchParams = searchFilter.toObject $routeParams.q
query = angular.extend limit: 20, searchParams
store.SearchResource.get query, ({rows}) ->
annotationMapper.loadAnnotations(rows)
@@ -35,6 +41,3 @@ module.exports = class StreamController
$scope.sort.name = 'Newest'
$scope.shouldShowThread = (container) -> true
-
- $scope.$on '$destroy', ->
- $scope.search.query = ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment