summary refs log tree commit diff
path: root/webclient/app-controller.js
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-08-15 13:43:07 +0100
committerKegan Dougal <kegan@matrix.org>2014-08-15 14:06:56 +0100
commit7ddb7a5cbbe9e4576742dc060ba35ca863b8d8b0 (patch)
tree395bea9a7d9f95fab285ed9a68d8354dec016ff4 /webclient/app-controller.js
parentStore messages in $rootScope so they can be accessed from multiple controller... (diff)
downloadsynapse-7ddb7a5cbbe9e4576742dc060ba35ca863b8d8b0.tar.xz
Event streaming now happens on an app level, rather than a per-room level. Make eventStreamService manage it's own repolling provided no one calls stop() on it. Couple the stream with eventHandlerService so any controller can just blithely call eventStreamService.resume() and expect to 'get stuff' without having to handle promises (though resume() still returns a promise for that request and proxies it through $q). Kill and reset the stream if you logout.
Diffstat (limited to 'webclient/app-controller.js')
-rw-r--r--webclient/app-controller.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/webclient/app-controller.js b/webclient/app-controller.js
index 086fa3d946..7f5f93ef72 100644
--- a/webclient/app-controller.js
+++ b/webclient/app-controller.js
@@ -21,8 +21,8 @@ limitations under the License.
 'use strict';
 
 angular.module('MatrixWebClientController', ['matrixService'])
-.controller('MatrixWebClientController', ['$scope', '$location', '$rootScope', 'matrixService',
-                               function($scope, $location, $rootScope, matrixService) {
+.controller('MatrixWebClientController', ['$scope', '$location', '$rootScope', 'matrixService', 'eventStreamService',
+                               function($scope, $location, $rootScope, matrixService, eventStreamService) {
          
     // Check current URL to avoid to display the logout button on the login page
     $scope.location = $location.path();
@@ -44,11 +44,15 @@ angular.module('MatrixWebClientController', ['matrixService'])
         else {
             $scope.config = matrixService.config();        
         }
-    };    
-    
+    };
+
+    eventStreamService.resume();
     
     // Logs the user out 
     $scope.logout = function() {
+        // kill the event stream
+        eventStreamService.stop();
+    
         // Clean permanent data
         matrixService.setConfig({});
         matrixService.saveConfig();
@@ -57,7 +61,7 @@ angular.module('MatrixWebClientController', ['matrixService'])
         $location.path("login");
     };
 
-    // Listen to the event indicating that the access token is no more valid.
+    // Listen to the event indicating that the access token is no longer valid.
     // In this case, the user needs to log in again.
     $scope.$on("M_UNKNOWN_TOKEN", function() {
         console.log("Invalid access token -> log user out");
@@ -65,4 +69,4 @@ angular.module('MatrixWebClientController', ['matrixService'])
     });
 }]);
 
-   
\ No newline at end of file
+