mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-09-07 02:21:56 +00:00
Use modelService for getting current presence state rather than RoomController.members
This commit is contained in:
parent
b8eca1ffbf
commit
d5a42e9d9c
@ -36,6 +36,11 @@ angular.module('modelService', [])
|
||||
aliasToRoomId[alias] = roomId;
|
||||
};
|
||||
|
||||
// user > room member lookups
|
||||
var userIdToRoomMember = {
|
||||
// user_id: [RoomMember, RoomMember, ...]
|
||||
};
|
||||
|
||||
/***** Room Object *****/
|
||||
var Room = function Room(room_id) {
|
||||
this.room_id = room_id;
|
||||
@ -115,9 +120,17 @@ angular.module('modelService', [])
|
||||
storeStateEvent: function storeState(event) {
|
||||
this.state_events[event.type + event.state_key] = event;
|
||||
if (event.type === "m.room.member") {
|
||||
var userId = event.state_key;
|
||||
var rm = new RoomMember();
|
||||
rm.event = event;
|
||||
this.members[event.state_key] = rm;
|
||||
rm.user = users[userId];
|
||||
this.members[userId] = rm;
|
||||
|
||||
// add to lookup so new m.presence events update the user
|
||||
if (!userIdToRoomMember[userId]) {
|
||||
userIdToRoomMember[userId] = [];
|
||||
}
|
||||
userIdToRoomMember[userId].push(rm);
|
||||
}
|
||||
else if (event.type === "m.room.aliases") {
|
||||
setRoomIdToAliasMapping(event.room_id, event.content.aliases[0]);
|
||||
@ -229,6 +242,14 @@ angular.module('modelService', [])
|
||||
var usr = new User();
|
||||
usr.event = event;
|
||||
users[event.content.user_id] = usr;
|
||||
// update room members
|
||||
var roomMembers = userIdToRoomMember[event.content.user_id];
|
||||
if (roomMembers) {
|
||||
for (var i=0; i<roomMembers.length; i++) {
|
||||
var rm = roomMembers[i];
|
||||
rm.user = usr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -127,7 +127,7 @@
|
||||
|
||||
<div id="usersTableWrapper" ng-hide="state.permission_denied">
|
||||
<div ng-repeat="member in members | orderMembersList" class="userAvatar">
|
||||
<div class="userAvatarFrame" ng-class="(member.presence === 'online' ? 'online' : (member.presence === 'unavailable' ? 'unavailable' : '')) + ' ' + (member.membership == 'invite' ? 'invited' : '')">
|
||||
<div class="userAvatarFrame" ng-class="(room.now.members[member.id].user.event.content.presence === 'online' ? 'online' : (room.now.members[member.id].user.event.content.presence === 'unavailable' ? 'unavailable' : '')) + ' ' + (member.membership == 'invite' ? 'invited' : '')">
|
||||
<img class="userAvatarImage mouse-pointer"
|
||||
ng-click="$parent.goToUserPage(member.id)"
|
||||
ng-src="{{member.avatar_url || 'img/default-profile.png'}}"
|
||||
|
Loading…
Reference in New Issue
Block a user