From b5c9d99424b269d291973e09c8311bbae3537596 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 22 Sep 2014 17:42:53 +0100 Subject: [PATCH] Show display name changes in the message list. --- .../matrix/event-handler-service.js | 28 +++++++++++++++---- webclient/room/room.html | 10 +++++-- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index 98003e97bf..21066e3d9f 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -253,12 +253,30 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) { // Exception: Do not do this if the event is a room state event because such events already come // as room messages events. Moreover, when they come as room messages events, they are relatively ordered // with other other room messages - if (event.content.prev !== event.content.membership && !isStateEvent) { - if (isLiveEvent) { - $rootScope.events.rooms[event.room_id].messages.push(event); + if (!isStateEvent) { + // could be a membership change, display name change, etc. + // Find out which one. + var memberChanges = undefined; + if (event.content.prev !== event.content.membership) { + memberChanges = "membership"; } - else { - $rootScope.events.rooms[event.room_id].messages.unshift(event); + else if (event.prev_content.displayname !== + event.content.displayname) { + memberChanges = "displayname"; + } + + // mark the key which changed + event.changedKey = memberChanges; + + // If there was a change we want to display, dump it in the message + // list. + if (memberChanges) { + if (isLiveEvent) { + $rootScope.events.rooms[event.room_id].messages.push(event); + } + else { + $rootScope.events.rooms[event.room_id].messages.unshift(event); + } } } diff --git a/webclient/room/room.html b/webclient/room/room.html index db3aa193c5..c807e2afe1 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -77,10 +77,10 @@
- + {{ members[msg.state_key].displayname || msg.state_key }} joined - + {{ members[msg.state_key].displayname || msg.state_key }} left @@ -93,7 +93,8 @@ - + {{ members[msg.user_id].displayname || msg.user_id }} {{ {"invite": "invited", "ban": "banned"}[msg.content.membership] }} {{ members[msg.state_key].displayname || msg.state_key }} @@ -101,6 +102,9 @@ : {{ msg.content.reason }} + + {{ msg.user_id }} changed their display name from {{ msg.prev_content.displayname }} to {{ msg.content.displayname }} +