mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-09-09 14:12:13 +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;
|
aliasToRoomId[alias] = roomId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// user > room member lookups
|
||||||
|
var userIdToRoomMember = {
|
||||||
|
// user_id: [RoomMember, RoomMember, ...]
|
||||||
|
};
|
||||||
|
|
||||||
/***** 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;
|
||||||
@ -115,9 +120,17 @@ angular.module('modelService', [])
|
|||||||
storeStateEvent: function storeState(event) {
|
storeStateEvent: function storeState(event) {
|
||||||
this.state_events[event.type + event.state_key] = event;
|
this.state_events[event.type + event.state_key] = event;
|
||||||
if (event.type === "m.room.member") {
|
if (event.type === "m.room.member") {
|
||||||
|
var userId = event.state_key;
|
||||||
var rm = new RoomMember();
|
var rm = new RoomMember();
|
||||||
rm.event = event;
|
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") {
|
else if (event.type === "m.room.aliases") {
|
||||||
setRoomIdToAliasMapping(event.room_id, event.content.aliases[0]);
|
setRoomIdToAliasMapping(event.room_id, event.content.aliases[0]);
|
||||||
@ -229,6 +242,14 @@ angular.module('modelService', [])
|
|||||||
var usr = new User();
|
var usr = new User();
|
||||||
usr.event = event;
|
usr.event = event;
|
||||||
users[event.content.user_id] = usr;
|
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 id="usersTableWrapper" ng-hide="state.permission_denied">
|
||||||
<div ng-repeat="member in members | orderMembersList" class="userAvatar">
|
<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"
|
<img class="userAvatarImage mouse-pointer"
|
||||||
ng-click="$parent.goToUserPage(member.id)"
|
ng-click="$parent.goToUserPage(member.id)"
|
||||||
ng-src="{{member.avatar_url || 'img/default-profile.png'}}"
|
ng-src="{{member.avatar_url || 'img/default-profile.png'}}"
|
||||||
|
Loading…
Reference in New Issue
Block a user