mirror of
https://mau.dev/maunium/synapse.git
synced 2024-11-17 23:42:33 +01:00
Clean data when user logs out
This commit is contained in:
parent
cc2cee4af6
commit
3ed39ad20e
4 changed files with 36 additions and 11 deletions
|
@ -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();
|
||||
|
@ -73,7 +73,10 @@ angular.module('MatrixWebClientController', ['matrixService', 'mPresence', 'even
|
|||
// Clean permanent data
|
||||
matrixService.setConfig({});
|
||||
matrixService.saveConfig();
|
||||
|
||||
|
||||
// Reset cached data
|
||||
eventHandlerService.reset();
|
||||
|
||||
// And go to the login page
|
||||
$location.url("login");
|
||||
};
|
||||
|
|
|
@ -36,13 +36,19 @@ 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;
|
||||
|
||||
var reset = function() {
|
||||
initialSyncDeferred = $q.defer();
|
||||
|
||||
$rootScope.events = {
|
||||
rooms: {} // will contain roomId: { messages:[], members:{userid1: event} }
|
||||
};
|
||||
}
|
||||
reset();
|
||||
|
||||
var initialSyncDeferred = $q.defer();
|
||||
|
||||
$rootScope.events = {
|
||||
rooms: {} // will contain roomId: { messages:[], members:{userid1: event} }
|
||||
};
|
||||
|
||||
// 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)
|
||||
|
@ -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
|
||||
|
@ -139,6 +139,11 @@ angular.module('RecentsController', ['matrixService', 'matrixFilter', 'eventHand
|
|||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// Clean data when user logs out
|
||||
$scope.$on(eventHandlerService.RESET_EVENT, function() {
|
||||
|
||||
delete $rootScope.rooms;
|
||||
});
|
||||
}]);
|
||||
|
||||
|
|
Loading…
Reference in a new issue