0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-14 12:43:50 +01:00

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.
This commit is contained in:
Kegan Dougal 2014-11-04 10:30:34 +00:00
parent 1c86ec5b8d
commit 5949571fe7
4 changed files with 12 additions and 9 deletions

View file

@ -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

View file

@ -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);

View file

@ -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

View file

@ -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>