diff options
author | Kegan Dougal <kegan@matrix.org> | 2014-11-14 11:59:33 +0000 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2014-11-14 12:59:22 +0000 |
commit | d5a42e9d9ce773821b04e46cf5bf1f9117cd4718 (patch) | |
tree | dd39bbcfdae41957c13197c3dab12fe667739125 | |
parent | Merge pull request #13 from matrix-org/request_logging (diff) | |
download | synapse-d5a42e9d9ce773821b04e46cf5bf1f9117cd4718.tar.xz |
Use modelService for getting current presence state rather than RoomController.members
-rw-r--r-- | syweb/webclient/components/matrix/model-service.js | 23 | ||||
-rw-r--r-- | syweb/webclient/room/room.html | 2 |
2 files changed, 23 insertions, 2 deletions
diff --git a/syweb/webclient/components/matrix/model-service.js b/syweb/webclient/components/matrix/model-service.js index 7d7a61cbf8..80b40d8782 100644 --- a/syweb/webclient/components/matrix/model-service.js +++ b/syweb/webclient/components/matrix/model-service.js @@ -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; + } + } } }; diff --git a/syweb/webclient/room/room.html b/syweb/webclient/room/room.html index ee7c9777a9..d282a5dbe3 100644 --- a/syweb/webclient/room/room.html +++ b/syweb/webclient/room/room.html @@ -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'}}" |