mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-09-09 13:32:01 +00:00
Remove rootScope.presence and replaced with modelService.getUser/setUser.
This commit is contained in:
parent
afd2e214bc
commit
3916e23bbd
@ -43,16 +43,11 @@ function(matrixService, $rootScope, $q, $timeout, $filter, mPresence, notificati
|
||||
// of the app, given we never try to reap memory yet)
|
||||
var eventMap = {};
|
||||
|
||||
// TODO: Remove this and replace with modelService.User objects.
|
||||
$rootScope.presence = {};
|
||||
|
||||
var initialSyncDeferred;
|
||||
|
||||
var reset = function() {
|
||||
initialSyncDeferred = $q.defer();
|
||||
|
||||
$rootScope.presence = {};
|
||||
|
||||
eventMap = {};
|
||||
};
|
||||
reset();
|
||||
@ -268,7 +263,7 @@ function(matrixService, $rootScope, $q, $timeout, $filter, mPresence, notificati
|
||||
};
|
||||
|
||||
var handlePresence = function(event, isLiveEvent) {
|
||||
$rootScope.presence[event.content.user_id] = event;
|
||||
modelService.setUser(event);
|
||||
$rootScope.$broadcast(PRESENCE_EVENT, event, isLiveEvent);
|
||||
};
|
||||
|
||||
@ -332,7 +327,6 @@ function(matrixService, $rootScope, $q, $timeout, $filter, mPresence, notificati
|
||||
*/
|
||||
var getUserDisplayName = function(room_id, user_id, wrap) {
|
||||
var displayName;
|
||||
// XXX: this is getting called *way* too often - at least once per every room member per every digest...
|
||||
|
||||
// Get the user display name from the member list of the room
|
||||
var member = modelService.getMember(room_id, user_id);
|
||||
@ -360,8 +354,11 @@ function(matrixService, $rootScope, $q, $timeout, $filter, mPresence, notificati
|
||||
|
||||
// The user may not have joined the room yet. So try to resolve display name from presence data
|
||||
// Note: This data may not be available
|
||||
if (undefined === displayName && user_id in $rootScope.presence) {
|
||||
displayName = $rootScope.presence[user_id].content.displayname;
|
||||
if (undefined === displayName) {
|
||||
var usr = modelService.getUser(user_id);
|
||||
if (usr) {
|
||||
displayName = usr.event.content.displayname;
|
||||
}
|
||||
}
|
||||
|
||||
if (undefined === displayName) {
|
||||
@ -374,8 +371,6 @@ function(matrixService, $rootScope, $q, $timeout, $filter, mPresence, notificati
|
||||
}
|
||||
}
|
||||
|
||||
//console.log("getUserDisplayName(" + room_id + ", " + user_id + ", " + wrap +") = " + displayName);
|
||||
|
||||
return displayName;
|
||||
};
|
||||
|
||||
|
@ -153,6 +153,10 @@ angular.module('modelService', [])
|
||||
// roomid: <Room>
|
||||
};
|
||||
|
||||
var users = {
|
||||
// user_id: <User>
|
||||
};
|
||||
|
||||
console.log("Models inited.");
|
||||
|
||||
return {
|
||||
@ -195,5 +199,15 @@ angular.module('modelService', [])
|
||||
return roomId;
|
||||
},
|
||||
|
||||
getUser: function(user_id) {
|
||||
return users[user_id];
|
||||
},
|
||||
|
||||
setUser: function(event) {
|
||||
var usr = new User();
|
||||
usr.event = event;
|
||||
users[event.content.user_id] = usr;
|
||||
}
|
||||
|
||||
};
|
||||
}]);
|
||||
|
@ -310,8 +310,9 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput', 'a
|
||||
}
|
||||
$scope.members[target_user_id] = chunk;
|
||||
|
||||
if (target_user_id in $rootScope.presence) {
|
||||
updatePresence($rootScope.presence[target_user_id]);
|
||||
var usr = modelService.getUser(target_user_id);
|
||||
if (usr) {
|
||||
updatePresence(usr.event);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user