diff options
author | Kegan Dougal <kegan@matrix.org> | 2014-11-04 10:30:34 +0000 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2014-11-04 10:30:34 +0000 |
commit | 5949571fe75eecefc9ff2433d9de46dfa5b80902 (patch) | |
tree | be2f0259bd8e245dfee66eabe6fdeba2608d088f /webclient | |
parent | Rejig display names when paginating to lie less. (diff) | |
download | synapse-5949571fe75eecefc9ff2433d9de46dfa5b80902.tar.xz |
SYWEB-116: Implement historical display name support.
This works for both live and paginated events. Each 'message' event has an associated '__room_member' key which points to the state of the sender at that point in time. Invites have an additional key '__target_room_member' which point to the state of the invitee at that point in time. This obviates the need for mapping user_ids to *current* displaynames in the message list, though this is still required for the user/presence list.
Diffstat (limited to '')
-rw-r--r-- | webclient/components/matrix/event-handler-service.js | 4 | ||||
-rw-r--r-- | webclient/components/matrix/model-service.js | 2 | ||||
-rw-r--r-- | webclient/room/room-controller.js | 3 | ||||
-rw-r--r-- | webclient/room/room.html | 12 |
4 files changed, 12 insertions, 9 deletions
diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index 226db0798b..027c80a1b6 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -213,7 +213,9 @@ function(matrixService, $rootScope, $q, $timeout, mPresence, notificationService // The events are copied to avoid referencing the same event when adding // the message (circular json structures) if (isStateEvent || isLiveEvent) { - room.current_room_state.storeStateEvent(angular.copy(event)); + var newEvent = angular.copy(event); + newEvent.cnt = event.content; + room.current_room_state.storeStateEvent(newEvent); } else if (!isLiveEvent) { // mutate the old room state diff --git a/webclient/components/matrix/model-service.js b/webclient/components/matrix/model-service.js index 7277ae347b..8b2ee877b1 100644 --- a/webclient/components/matrix/model-service.js +++ b/webclient/components/matrix/model-service.js @@ -46,7 +46,7 @@ angular.module('modelService', []) // every message must reference the RoomMember which made it *at // that time* so things like display names display correctly. var stateAtTheTime = toFront ? this.old_room_state : this.current_room_state; - event.room_member = stateAtTheTime.getStateEvent("m.room.member", event.user_id); + event.__room_member = stateAtTheTime.getStateEvent("m.room.member", event.user_id); if (event.type === "m.room.member" && event.content.membership === "invite") { // give information on both the inviter and invitee event.__target_room_member = stateAtTheTime.getStateEvent("m.room.member", event.state_key); diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js index 0bcc33ab4f..2e0f5faff0 100644 --- a/webclient/room/room-controller.js +++ b/webclient/room/room-controller.js @@ -1007,7 +1007,8 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput']) $scope.event_selected = angular.copy(content); // FIXME: Pre-calculated event data should be stripped in a nicer way. - $scope.event_selected.room_member = undefined; + $scope.event_selected.__room_member = undefined; + $scope.event_selected.__target_room_member = undefined; // scope this so the template can check power levels and enable/disable // buttons diff --git a/webclient/room/room.html b/webclient/room/room.html index 332a9928d1..407daf56ff 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -127,15 +127,15 @@ <tr ng-repeat="msg in room.events" ng-class="(room.events[$index + 1].user_id !== msg.user_id ? 'differentUser' : '') + (msg.user_id === state.user_id ? ' mine' : '')" scroll-item> <td class="leftBlock"> - <div class="sender" ng-hide="room.events[$index - 1].user_id === msg.user_id"> {{ msg.room_member.cnt.displayname || msg.user_id | mUserDisplayName: room_id }}</div> + <div class="sender" ng-hide="room.events[$index - 1].user_id === msg.user_id"> {{ msg.__room_member.cnt.displayname || msg.user_id | mUserDisplayName: room_id }}</div> <div class="timestamp" ng-class="msg.echo_msg_state"> {{ (msg.origin_server_ts) | date:'MMM d HH:mm' }} </div> </td> <td class="avatar"> - <!-- msg.room_member.avatar_url is just backwards compat, and can be removed in the future. --> - <img class="avatarImage" ng-src="{{ msg.room_member.cnt.avatar_url || msg.room_member.avatar_url || 'img/default-profile.png' }}" width="32" height="32" title="{{msg.user_id}}" + <!-- msg.__room_member.avatar_url is just backwards compat, and can be removed in the future. --> + <img class="avatarImage" ng-src="{{ msg.__room_member.cnt.avatar_url || msg.__room_member.avatar_url || 'img/default-profile.png' }}" width="32" height="32" title="{{msg.user_id}}" ng-hide="room.events[$index - 1].user_id === msg.user_id || msg.user_id === state.user_id"/> </td> <td ng-class="(!msg.content.membership && ('m.room.topic' !== msg.type && 'm.room.name' !== msg.type))? (msg.content.msgtype === 'm.emote' ? 'emote text' : 'text') : 'membership text'"> @@ -146,7 +146,7 @@ <span ng-if="'leave' === msg.content.membership && msg.changedKey === 'membership'"> <span ng-if="msg.user_id === msg.state_key"> <!-- FIXME: This seems like a synapse bug that the 'leave' content doesn't give the displayname... --> - {{ msg.room_member.cnt.displayname || members[msg.state_key].displayname || msg.state_key }} left + {{ msg.__room_member.cnt.displayname || members[msg.state_key].displayname || msg.state_key }} left </span> <span ng-if="msg.user_id !== msg.state_key && msg.prev_content"> {{ msg.content.displayname || members[msg.user_id].displayname || msg.user_id }} @@ -159,9 +159,9 @@ </span> <span ng-if="'invite' === msg.content.membership && msg.changedKey === 'membership' || 'ban' === msg.content.membership && msg.changedKey === 'membership'"> - {{ msg.content.displayname || members[msg.user_id].displayname || msg.user_id }} + {{ msg.__room_member.cnt.displayname || msg.user_id }} {{ {"invite": "invited", "ban": "banned"}[msg.content.membership] }} - {{ msg.__target_room_member.displayname || msg.state_key }} + {{ msg.__target_room_member.cnt.displayname || msg.state_key }} <span ng-if="msg.prev_content && 'ban' === msg.prev_content.membership && msg.content.reason"> : {{ msg.content.reason }} </span> |