summary refs log tree commit diff
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-11-17 10:12:44 +0000
committerKegan Dougal <kegan@matrix.org>2014-11-17 11:04:10 +0000
commit7799e14121107417ef0de5881b23e0c74394575c (patch)
treeacca4e373936e0e470b59ad5e9d4cb00bda79cba
parentThese lines aren't doing anything (diff)
downloadsynapse-7799e14121107417ef0de5881b23e0c74394575c.tar.xz
Add clearRooms() to wipe data when you logout.
-rw-r--r--syweb/webclient/app-controller.js1
-rw-r--r--syweb/webclient/components/matrix/event-handler-service.js1
-rw-r--r--syweb/webclient/components/matrix/model-service.js43
3 files changed, 29 insertions, 16 deletions
diff --git a/syweb/webclient/app-controller.js b/syweb/webclient/app-controller.js
index 582c075e3d..46890c2287 100644
--- a/syweb/webclient/app-controller.js
+++ b/syweb/webclient/app-controller.js
@@ -85,6 +85,7 @@ angular.module('MatrixWebClientController', ['matrixService', 'mPresence', 'even
         matrixService.saveConfig();
 
         // Reset cached data
+        modelService.clearRooms();
         eventHandlerService.reset();
 
         // And go to the login page
diff --git a/syweb/webclient/components/matrix/event-handler-service.js b/syweb/webclient/components/matrix/event-handler-service.js
index 20ed89f161..2d8f25f0b4 100644
--- a/syweb/webclient/components/matrix/event-handler-service.js
+++ b/syweb/webclient/components/matrix/event-handler-service.js
@@ -47,7 +47,6 @@ function(matrixService, $rootScope, $q, $timeout, $filter, mPresence, notificati
 
     var reset = function() {
         initialSyncDeferred = $q.defer();
-
         eventMap = {};
     };
     reset();
diff --git a/syweb/webclient/components/matrix/model-service.js b/syweb/webclient/components/matrix/model-service.js
index d34981a9ff..0ec919b637 100644
--- a/syweb/webclient/components/matrix/model-service.js
+++ b/syweb/webclient/components/matrix/model-service.js
@@ -29,18 +29,38 @@ angular.module('modelService', [])
 .factory('modelService', ['matrixService', function(matrixService) {
 
     // alias / id lookups
-    var roomIdToAlias = {};
-    var aliasToRoomId = {};
+    var roomIdToAlias, aliasToRoomId;
     var setRoomIdToAliasMapping = function(roomId, alias) {
         roomIdToAlias[roomId] = alias;
         aliasToRoomId[alias] = roomId;
     };
     
     // user > room member lookups
-    var userIdToRoomMember = {
-        // user_id: [RoomMember, RoomMember, ...]
+    var userIdToRoomMember;
+    
+    // main store
+    var rooms, users;
+    
+    var init = function() {
+        roomIdToAlias = {};
+        aliasToRoomId = {};
+        userIdToRoomMember = {
+            // user_id: [RoomMember, RoomMember, ...]
+        };
+        
+        // rooms are stored here when they come in.
+        rooms = {
+            // roomid: <Room>
+        };
+        
+        users = {
+            // user_id: <User>
+        };
+        console.log("Models inited.");
     };
     
+    init();
+    
     /***** Room Object *****/
     var Room = function Room(room_id) {
         this.room_id = room_id;
@@ -185,17 +205,6 @@ angular.module('modelService', [])
         this.last_updated = 0; // used with last_active_ago to work out last seen times
     };
     
-    // rooms are stored here when they come in.
-    var rooms = {
-        // roomid: <Room>
-    };
-    
-    var users = {
-        // user_id: <User>
-    };
-    
-    console.log("Models inited.");
-    
     return {
     
         getRoom: function(roomId) {
@@ -330,6 +339,10 @@ angular.module('modelService', [])
             }
 
             return lastMessage;
+        },
+        
+        clearRooms: function() {
+            init();
         }
     
     };