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 = [ ...@@ -12,6 +12,14 @@ imports = [
resolve = 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] store: ['store', (store) -> store.$promise]
......
...@@ -36,8 +36,7 @@ class AppController ...@@ -36,8 +36,7 @@ class AppController
oncancel = -> oncancel = ->
$scope.dialog.visible = false $scope.dialog.visible = false
$scope.$on '$routeChangeStart', (event, newRoute, oldRoute) -> cleanupAnnotations = ->
return if newRoute.redirectTo
# Clean up any annotations that need to be unloaded. # Clean up any annotations that need to be unloaded.
for id, container of $scope.threading.idTable when container.message for id, container of $scope.threading.idTable when container.message
# Remove annotations not belonging to this user when highlighting. # Remove annotations not belonging to this user when highlighting.
...@@ -76,6 +75,9 @@ class AppController ...@@ -76,6 +75,9 @@ class AppController
streamer.close() streamer.close()
streamer.open($window.WebSocket, streamerUrl) streamer.open($window.WebSocket, streamerUrl)
# Clean up annotations that should be removed
cleanupAnnotations()
# Reload the view. # Reload the view.
$route.reload() $route.reload()
......
...@@ -19,6 +19,11 @@ class StreamSearchController ...@@ -19,6 +19,11 @@ class StreamSearchController
terms = searchfilter.generateFacetedFilter $scope.search.query terms = searchfilter.generateFacetedFilter $scope.search.query
queryparser.populateFilter streamfilter, terms 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.isEmbedded = false
$scope.isStream = true $scope.isStream = true
...@@ -29,11 +34,5 @@ class StreamSearchController ...@@ -29,11 +34,5 @@ class StreamSearchController
$scope.$on '$destroy', -> $scope.$on '$destroy', ->
$scope.search.query = '' $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') angular.module('h')
.controller('StreamSearchController', StreamSearchController) .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