BF: presence and eventMap were not reset at logout.

This commit is contained in:
Emmanuel ROHEE 2014-09-15 10:39:30 +02:00
parent f3d3441d02
commit a9da2ec895
1 changed files with 14 additions and 10 deletions

View File

@ -38,6 +38,13 @@ angular.module('eventHandlerService', [])
var TOPIC_EVENT = "TOPIC_EVENT"; var TOPIC_EVENT = "TOPIC_EVENT";
var RESET_EVENT = "RESET_EVENT"; // eventHandlerService has been resetted var RESET_EVENT = "RESET_EVENT"; // eventHandlerService has been resetted
// used for dedupping events - could be expanded in future...
// FIXME: means that we leak memory over time (along with lots of the rest
// of the app, given we never try to reap memory yet)
var eventMap = {};
$rootScope.presence = {};
var initialSyncDeferred; var initialSyncDeferred;
var reset = function() { var reset = function() {
@ -46,16 +53,13 @@ angular.module('eventHandlerService', [])
$rootScope.events = { $rootScope.events = {
rooms: {} // will contain roomId: { messages:[], members:{userid1: event} } rooms: {} // will contain roomId: { messages:[], members:{userid1: event} }
}; };
}
reset();
// used for dedupping events - could be expanded in future...
// FIXME: means that we leak memory over time (along with lots of the rest
// of the app, given we never try to reap memory yet)
var eventMap = {};
$rootScope.presence = {}; $rootScope.presence = {};
eventMap = {};
};
reset();
var initRoom = function(room_id) { var initRoom = function(room_id) {
if (!(room_id in $rootScope.events.rooms)) { if (!(room_id in $rootScope.events.rooms)) {
console.log("Creating new handler entry for " + room_id); console.log("Creating new handler entry for " + room_id);
@ -204,7 +208,7 @@ angular.module('eventHandlerService', [])
var handleCallEvent = function(event, isLiveEvent) { var handleCallEvent = function(event, isLiveEvent) {
$rootScope.$broadcast(CALL_EVENT, event, isLiveEvent); $rootScope.$broadcast(CALL_EVENT, event, isLiveEvent);
if (event.type == 'm.call.invite') { if (event.type === 'm.call.invite') {
$rootScope.events.rooms[event.room_id].messages.push(event); $rootScope.events.rooms[event.room_id].messages.push(event);
} }
}; };
@ -231,7 +235,7 @@ angular.module('eventHandlerService', [])
} }
} }
return index; return index;
} };
return { return {
ROOM_CREATE_EVENT: ROOM_CREATE_EVENT, ROOM_CREATE_EVENT: ROOM_CREATE_EVENT,