mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-14 22:53:52 +01:00
Add clearRooms() to wipe data when you logout.
This commit is contained in:
parent
2eaf689f71
commit
7799e14121
3 changed files with 29 additions and 16 deletions
|
@ -85,6 +85,7 @@ angular.module('MatrixWebClientController', ['matrixService', 'mPresence', 'even
|
||||||
matrixService.saveConfig();
|
matrixService.saveConfig();
|
||||||
|
|
||||||
// Reset cached data
|
// Reset cached data
|
||||||
|
modelService.clearRooms();
|
||||||
eventHandlerService.reset();
|
eventHandlerService.reset();
|
||||||
|
|
||||||
// And go to the login page
|
// And go to the login page
|
||||||
|
|
|
@ -47,7 +47,6 @@ function(matrixService, $rootScope, $q, $timeout, $filter, mPresence, notificati
|
||||||
|
|
||||||
var reset = function() {
|
var reset = function() {
|
||||||
initialSyncDeferred = $q.defer();
|
initialSyncDeferred = $q.defer();
|
||||||
|
|
||||||
eventMap = {};
|
eventMap = {};
|
||||||
};
|
};
|
||||||
reset();
|
reset();
|
||||||
|
|
|
@ -29,18 +29,38 @@ angular.module('modelService', [])
|
||||||
.factory('modelService', ['matrixService', function(matrixService) {
|
.factory('modelService', ['matrixService', function(matrixService) {
|
||||||
|
|
||||||
// alias / id lookups
|
// alias / id lookups
|
||||||
var roomIdToAlias = {};
|
var roomIdToAlias, aliasToRoomId;
|
||||||
var aliasToRoomId = {};
|
|
||||||
var setRoomIdToAliasMapping = function(roomId, alias) {
|
var setRoomIdToAliasMapping = function(roomId, alias) {
|
||||||
roomIdToAlias[roomId] = alias;
|
roomIdToAlias[roomId] = alias;
|
||||||
aliasToRoomId[alias] = roomId;
|
aliasToRoomId[alias] = roomId;
|
||||||
};
|
};
|
||||||
|
|
||||||
// user > room member lookups
|
// user > room member lookups
|
||||||
var userIdToRoomMember = {
|
var userIdToRoomMember;
|
||||||
// user_id: [RoomMember, RoomMember, ...]
|
|
||||||
|
// 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 *****/
|
/***** Room Object *****/
|
||||||
var Room = function Room(room_id) {
|
var Room = function Room(room_id) {
|
||||||
this.room_id = 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
|
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 {
|
return {
|
||||||
|
|
||||||
getRoom: function(roomId) {
|
getRoom: function(roomId) {
|
||||||
|
@ -330,6 +339,10 @@ angular.module('modelService', [])
|
||||||
}
|
}
|
||||||
|
|
||||||
return lastMessage;
|
return lastMessage;
|
||||||
|
},
|
||||||
|
|
||||||
|
clearRooms: function() {
|
||||||
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue