Commit bd0b5822 authored by Aron Carroll's avatar Aron Carroll

Merge pull request #1863 from hypothesis/view-resolve-auth

Resolve user authorization before view render.
parents d9f44498 ca2083cc
......@@ -12,6 +12,14 @@ imports = [
resolve =
auth: ['$q', '$rootScope', 'auth', ($q, $rootScope, auth) ->
dfd = $q.defer()
unwatch = $rootScope.$watch (-> auth.user), (user) ->
return if user is undefined
dfd.resolve(auth)
unwatch()
dfd.promise
]
store: ['store', (store) -> store.$promise]
......
......@@ -36,8 +36,7 @@ class AppController
oncancel = ->
$scope.dialog.visible = false
$scope.$on '$routeChangeStart', (event, newRoute, oldRoute) ->
return if newRoute.redirectTo
cleanupAnnotations = ->
# Clean up any annotations that need to be unloaded.
for id, container of $scope.threading.idTable when container.message
# Remove annotations not belonging to this user when highlighting.
......@@ -76,6 +75,9 @@ class AppController
streamer.close()
streamer.open($window.WebSocket, streamerUrl)
# Clean up annotations that should be removed
cleanupAnnotations()
# Reload the view.
$route.reload()
......
......@@ -19,6 +19,11 @@ class StreamSearchController
terms = searchfilter.generateFacetedFilter $scope.search.query
queryparser.populateFilter streamfilter, terms
# Perform the search
query = angular.extend limit: 10, $scope.search.query
store.SearchResource.get query, ({rows}) ->
annotator.loadAnnotations(rows)
$scope.isEmbedded = false
$scope.isStream = true
......@@ -29,11 +34,5 @@ class StreamSearchController
$scope.$on '$destroy', ->
$scope.search.query = ''
$scope.$watch (-> auth.user), ->
query = angular.extend limit: 10, $scope.search.query
store.SearchResource.get query, ({rows}) ->
annotator.loadAnnotations(rows)
angular.module('h')
.controller('StreamSearchController', StreamSearchController)
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