diff options
author | Kegan Dougal <kegan@matrix.org> | 2014-11-04 10:18:46 +0000 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2014-11-04 10:18:46 +0000 |
commit | 1c86ec5b8dcdfaf72259b63d2c588014707c70de (patch) | |
tree | e9ff65395af9216a17c3f83aaf54b543e2536b57 /webclient/components | |
parent | Rejig order of checks/state updates/message insertions for m.room.member. Mar... (diff) | |
download | synapse-1c86ec5b8dcdfaf72259b63d2c588014707c70de.tar.xz |
Rejig display names when paginating to lie less.
Diffstat (limited to 'webclient/components')
-rw-r--r-- | webclient/components/matrix/event-handler-service.js | 11 | ||||
-rw-r--r-- | webclient/components/matrix/model-service.js | 9 |
2 files changed, 15 insertions, 5 deletions
diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index bba24cfaa9..226db0798b 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -218,14 +218,19 @@ function(matrixService, $rootScope, $q, $timeout, mPresence, notificationService else if (!isLiveEvent) { // mutate the old room state var oldEvent = angular.copy(event); + oldEvent.cnt = event.content; if (event.prev_content) { // the m.room.member event we are handling is the NEW event. When // we keep going back in time, we want the PREVIOUS value for displaying // names/etc, hence the clobber here. - // FIXME TODO: We can't be doing this, we should have separate keys for - // avatar_url and displayname. - event.content = event.prev_content; + oldEvent.cnt = event.prev_content; } + + if (event.changedKey === "membership" && event.content.membership === "join") { + // join has a prev_content but it doesn't contain all the info unlike the join, so use that. + oldEvent.cnt = event.content; + } + room.old_room_state.storeStateEvent(oldEvent); } diff --git a/webclient/components/matrix/model-service.js b/webclient/components/matrix/model-service.js index d5acd7eda9..7277ae347b 100644 --- a/webclient/components/matrix/model-service.js +++ b/webclient/components/matrix/model-service.js @@ -45,12 +45,17 @@ angular.module('modelService', []) addMessageEvent: function addMessageEvent(event, toFront) { // 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); + 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); + } + if (toFront) { - event.room_member = this.old_room_state.getStateEvent("m.room.member", event.user_id); this.events.unshift(event); } else { - event.room_member = this.current_room_state.getStateEvent("m.room.member", event.user_id); this.events.push(event); } }, |