diff options
author | Emmanuel ROHEE <erohee@amdocs.com> | 2014-09-02 18:26:07 +0200 |
---|---|---|
committer | Emmanuel ROHEE <erohee@amdocs.com> | 2014-09-02 18:26:20 +0200 |
commit | 6e2ce83d577aaa446f345de90f36ae07171059a4 (patch) | |
tree | df183a0a6973ca35d2b117a10cfe2a065906a70c | |
parent | More formatting, more TODOs. Settled on a way of linking to external API docs... (diff) | |
download | synapse-6e2ce83d577aaa446f345de90f36ae07171059a4.tar.xz |
roomName directive: Take into account invited users.
Use the last user display name
-rw-r--r-- | webclient/app-filter.js | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/webclient/app-filter.js b/webclient/app-filter.js index b8d3d2a0d8..e0e8130e45 100644 --- a/webclient/app-filter.js +++ b/webclient/app-filter.js @@ -103,7 +103,44 @@ angular.module('matrixWebClient') for (var i in room.members) { var member = room.members[i]; if (member.user_id !== matrixService.config().user_id) { - roomName = member.content.displayname ? member.content.displayname : member.user_id; + + if (member.user_id in $rootScope.presence) { + // If the user is available in presence, use the displayname there + // as it is the most uptodate + roomName = $rootScope.presence[member.user_id].content.displayname; + } + else if (member.content.displayname) { + roomName = member.content.displayname; + } + else { + roomName = member.user_id; + } + } + } + } + else if (1 === Object.keys(room.members).length) { + // The other member may be in the invite list, get all invited users + var invitedUserIDs = []; + for (var i in room.messages) { + var message = room.messages[i]; + if ("m.room.member" === message.type && "invite" === message.membership) { + // Make sure there is no duplicate user + if (-1 === invitedUserIDs.indexOf(message.state_key)) { + invitedUserIDs.push(message.state_key); + } + } + } + + // For now, only 1:1 room needs to be renamed. It means only 1 invited user + if (1 === invitedUserIDs.length) { + var userID = invitedUserIDs[0]; + + // Try to resolve his displayname in presence global data + if (userID in $rootScope.presence) { + roomName = $rootScope.presence[userID].content.displayname; + } + else { + roomName = member.user_id; } } } |