summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-08-22 10:50:10 +0100
committerErik Johnston <erik@matrix.org>2014-08-22 10:51:00 +0100
commit74c90f78159e8067b25bfa8a009d2e68419947c8 (patch)
tree61a13587e176299667dcae796ccebf1563e5f34d
parentUse $location.url instead of $location.path to get clean page URL without has... (diff)
downloadsynapse-74c90f78159e8067b25bfa8a009d2e68419947c8.tar.xz
Reinitialize room when creating a RoomController so that we start off with a clean slate, as it expects/
-rw-r--r--webclient/components/matrix/event-handler-service.js12
-rw-r--r--webclient/room/room-controller.js2
2 files changed, 13 insertions, 1 deletions
diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js
index 6a01b3fb55..aa8867425e 100644
--- a/webclient/components/matrix/event-handler-service.js
+++ b/webclient/components/matrix/event-handler-service.js
@@ -44,6 +44,12 @@ angular.module('eventHandlerService', [])
             $rootScope.events.rooms[room_id].members = {};
         }
     }
+
+    var reInitRoom = function(room_id) {
+        $rootScope.events.rooms[room_id] = {};
+        $rootScope.events.rooms[room_id].messages = [];
+        $rootScope.events.rooms[room_id].members = {};
+    }
     
     var handleMessage = function(event, isLiveEvent) {
         if ("membership_target" in event.content) {
@@ -118,6 +124,10 @@ angular.module('eventHandlerService', [])
             for (var i=0; i<events.length; i++) {
                 this.handleEvent(events[i], isLiveEvents);
             }
-        }
+        },
+
+        reInitRoom: function(room_id) {
+            reInitRoom(room_id);
+        },
     };
 }]);
diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js
index 26d1836fc2..a0485e84e8 100644
--- a/webclient/room/room-controller.js
+++ b/webclient/room/room-controller.js
@@ -316,6 +316,8 @@ angular.module('RoomController', ['ngSanitize', 'mUtilities'])
     };
 
     var onInit2 = function() {
+        eventHandlerService.reInitRoom($scope.room_id); 
+
         // Join the room
         matrixService.join($scope.room_id).then(
             function() {