summary refs log tree commit diff
path: root/webclient/room
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-08-15 10:20:14 +0100
committerKegan Dougal <kegan@matrix.org>2014-08-15 14:06:56 +0100
commit8bf3994c2e4726278355bc1398c4b9c94d242ad0 (patch)
treedce0066c2e6aec0e3657606468df16a439c450f8 /webclient/room
parentAdd a check to make sure that during state conflict res we only request a PDU... (diff)
downloadsynapse-8bf3994c2e4726278355bc1398c4b9c94d242ad0.tar.xz
Added event stream service which neatly blobs together requests / state for the event stream. This depends on matrix service to do the actual hit. Currently this has exactly the same behaviour as before.
Diffstat (limited to '')
-rw-r--r--webclient/room/room-controller.js23
1 files changed, 10 insertions, 13 deletions
diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js
index fb6e2025fc..3f69a12c23 100644
--- a/webclient/room/room-controller.js
+++ b/webclient/room/room-controller.js
@@ -15,8 +15,8 @@ limitations under the License.
 */
 
 angular.module('RoomController', [])
-.controller('RoomController', ['$scope', '$http', '$timeout', '$routeParams', '$location', 'matrixService',
-                               function($scope, $http, $timeout, $routeParams, $location, matrixService) {
+.controller('RoomController', ['$scope', '$http', '$timeout', '$routeParams', '$location', 'matrixService', 'eventStreamService',
+                               function($scope, $http, $timeout, $routeParams, $location, matrixService, eventStreamService) {
    'use strict';
     var MESSAGES_PER_PAGINATION = 10;
     $scope.room_id = $routeParams.room_id;
@@ -83,13 +83,8 @@ angular.module('RoomController', [])
     };
 
     var shortPoll = function() {
-        $http.get(matrixService.config().homeserver + matrixService.prefix + "/events", {
-            "params": {
-                "access_token": matrixService.config().access_token,
-                "from": $scope.state.events_from,
-                "timeout": 5000
-            }})
-            .then(function(response) {
+        eventStreamService.resume().then(
+            function(response) {
                 $scope.state.stream_failure = undefined;
                 console.log("Got response from "+$scope.state.events_from+" to "+response.data.end);
                 $scope.state.events_from = response.data.end;
@@ -103,10 +98,11 @@ angular.module('RoomController', [])
                 else {
                     $timeout(shortPoll, 0);
                 }
-            }, function(response) {
-                $scope.state.stream_failure = response;
+            }, 
+            function(error) {
+                $scope.state.stream_failure = error;
 
-                if (response.status == 403) {
+                if (error.status == 403) {
                     $scope.stopPoll = true;
                 }
                 
@@ -116,7 +112,8 @@ angular.module('RoomController', [])
                 else {
                     $timeout(shortPoll, 5000);
                 }
-            });
+            }
+        );
     };
 
     var updateMemberList = function(chunk) {