Clean data when user logs out
This commit is contained in:
parent
cc2cee4af6
commit
3ed39ad20e
|
@ -21,8 +21,8 @@ limitations under the License.
|
|||
'use strict';
|
||||
|
||||
angular.module('MatrixWebClientController', ['matrixService', 'mPresence', 'eventStreamService'])
|
||||
.controller('MatrixWebClientController', ['$scope', '$location', '$rootScope', '$timeout', '$animate', 'matrixService', 'mPresence', 'eventStreamService', 'matrixPhoneService',
|
||||
function($scope, $location, $rootScope, $timeout, $animate, matrixService, mPresence, eventStreamService, matrixPhoneService) {
|
||||
.controller('MatrixWebClientController', ['$scope', '$location', '$rootScope', '$timeout', '$animate', 'matrixService', 'mPresence', 'eventStreamService', 'eventHandlerService', 'matrixPhoneService',
|
||||
function($scope, $location, $rootScope, $timeout, $animate, matrixService, mPresence, eventStreamService, eventHandlerService, matrixPhoneService) {
|
||||
|
||||
// Check current URL to avoid to display the logout button on the login page
|
||||
$scope.location = $location.path();
|
||||
|
@ -74,6 +74,9 @@ angular.module('MatrixWebClientController', ['matrixService', 'mPresence', 'even
|
|||
matrixService.setConfig({});
|
||||
matrixService.saveConfig();
|
||||
|
||||
// Reset cached data
|
||||
eventHandlerService.reset();
|
||||
|
||||
// And go to the login page
|
||||
$location.url("login");
|
||||
};
|
||||
|
|
|
@ -36,12 +36,18 @@ angular.module('eventHandlerService', [])
|
|||
var CALL_EVENT = "CALL_EVENT";
|
||||
var NAME_EVENT = "NAME_EVENT";
|
||||
var TOPIC_EVENT = "TOPIC_EVENT";
|
||||
var RESET_EVENT = "RESET_EVENT"; // eventHandlerService has been resetted
|
||||
|
||||
var initialSyncDeferred = $q.defer();
|
||||
var initialSyncDeferred;
|
||||
|
||||
$rootScope.events = {
|
||||
rooms: {} // will contain roomId: { messages:[], members:{userid1: event} }
|
||||
};
|
||||
var reset = function() {
|
||||
initialSyncDeferred = $q.defer();
|
||||
|
||||
$rootScope.events = {
|
||||
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
|
||||
|
@ -236,6 +242,12 @@ angular.module('eventHandlerService', [])
|
|||
CALL_EVENT: CALL_EVENT,
|
||||
NAME_EVENT: NAME_EVENT,
|
||||
TOPIC_EVENT: TOPIC_EVENT,
|
||||
RESET_EVENT: RESET_EVENT,
|
||||
|
||||
reset: function() {
|
||||
reset();
|
||||
$rootScope.$broadcast(RESET_EVENT);
|
||||
},
|
||||
|
||||
handleEvent: function(event, isLiveEvent, isStateEvent) {
|
||||
|
||||
|
|
|
@ -142,4 +142,9 @@ angular.module('HomeController', ['matrixService', 'eventHandlerService', 'Recen
|
|||
|
||||
refresh();
|
||||
};
|
||||
|
||||
// Clean data when user logs out
|
||||
$scope.$on(eventHandlerService.RESET_EVENT, function() {
|
||||
$scope.public_rooms = [];
|
||||
});
|
||||
}]);
|
||||
|
|
|
@ -102,7 +102,7 @@ angular.module('RecentsController', ['matrixService', 'matrixFilter', 'eventHand
|
|||
}
|
||||
|
||||
return memberCount;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.onInit = function() {
|
||||
// Init recents list only once
|
||||
|
@ -140,5 +140,10 @@ angular.module('RecentsController', ['matrixService', 'matrixFilter', 'eventHand
|
|||
);
|
||||
};
|
||||
|
||||
// Clean data when user logs out
|
||||
$scope.$on(eventHandlerService.RESET_EVENT, function() {
|
||||
|
||||
delete $rootScope.rooms;
|
||||
});
|
||||
}]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue