summary refs log tree commit diff
diff options
context:
space:
mode:
authorEmmanuel ROHEE <erohee@amdocs.com>2014-09-01 18:50:39 +0200
committerEmmanuel ROHEE <erohee@amdocs.com>2014-09-01 18:52:24 +0200
commit7d99cee3ef9e84ea24755ef9097342cf631cda59 (patch)
tree4cf67374b020a33f423cd763c7899b8500a0a89d
parentLittle bit more on syncing APIs, need to know more about responses before mor... (diff)
downloadsynapse-7d99cee3ef9e84ea24755ef9097342cf631cda59.tar.xz
Added roomName, a directive to compute a room name based on its alias (not aliases for now) and its users displaynames or ids
Diffstat (limited to '')
-rw-r--r--webclient/app-filter.js39
-rw-r--r--webclient/recents/recents-controller.js7
-rw-r--r--webclient/recents/recents.html2
-rw-r--r--webclient/room/room.html2
4 files changed, 45 insertions, 5 deletions
diff --git a/webclient/app-filter.js b/webclient/app-filter.js
index b8f4ed25bc..124f4ebb48 100644
--- a/webclient/app-filter.js
+++ b/webclient/app-filter.js
@@ -79,4 +79,43 @@ angular.module('matrixWebClient')
     return function(text) {
         return $sce.trustAsHtml(text);
     };
+}])
+
+// Compute the room name according to information we have
+.filter('roomName', ['$rootScope', 'matrixService', function($rootScope, matrixService) {
+    return function(room_id) {
+        var roomName;
+
+        // If there is an alias, use it
+        // TODO: only one alias is managed for now
+        var alias = matrixService.getRoomIdToAliasMapping(room_id);
+        if (alias) {
+            roomName = alias;
+        }
+
+        if (undefined === roomName) {
+            // Else, build the name from its users
+            var room = $rootScope.events.rooms[room_id];
+            if (room) {
+                if (room.members) {
+                    // Limit the room renaming to 1:1 room
+                    if (2 === Object.keys(room.members).length) {
+                        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 (undefined === roomName) {
+            // By default, use the room ID
+            roomName = room_id;
+        }
+
+        return roomName;
+    };
 }]);
diff --git a/webclient/recents/recents-controller.js b/webclient/recents/recents-controller.js
index c9fd022d7f..947bd29de3 100644
--- a/webclient/recents/recents-controller.js
+++ b/webclient/recents/recents-controller.js
@@ -33,8 +33,7 @@ angular.module('RecentsController', ['matrixService', 'eventHandlerService'])
                 console.log("Invited to room " + event.room_id);
                 // FIXME push membership to top level key to match /im/sync
                 event.membership = event.content.membership;
-                // FIXME bodge a nicer name than the room ID for this invite.
-                event.room_display_name = event.user_id + "'s room";
+
                 $scope.rooms[event.room_id] = event;
             }
         });
@@ -88,7 +87,9 @@ angular.module('RecentsController', ['matrixService', 'eventHandlerService'])
     };
 
     $scope.onInit = function() {
-        refresh();
+        eventHandlerService.waitForInitialSyncCompletion().then(function() {
+            refresh();
+        });
     };
     
 }]);
diff --git a/webclient/recents/recents.html b/webclient/recents/recents.html
index 56fb38b02a..db3b0fb32f 100644
--- a/webclient/recents/recents.html
+++ b/webclient/recents/recents.html
@@ -6,7 +6,7 @@
                ng-class="{'recentsRoomSelected': (room.room_id === recentsSelectedRoomID)}">
             <tr>
                 <td class="recentsRoomName">
-                    {{ room.room_display_name }}
+                    {{ room.room_id | roomName }}
                 </td>
                 <td class="recentsRoomSummaryTS">
                     {{ (room.lastMsg.ts) | date:'MMM d HH:mm' }}
diff --git a/webclient/room/room.html b/webclient/room/room.html
index c4d6ccd6cc..f118461e6b 100644
--- a/webclient/room/room.html
+++ b/webclient/room/room.html
@@ -3,7 +3,7 @@
     <div id="roomHeader">
         <a href ng-click="goToPage('/')"><img src="img/logo-small.png" width="100" height="43" alt="[matrix]"/></a>
         <div id="roomName">
-            {{ room_alias || room_id }}
+            {{ room_id  | roomName }}
         </div>
     </div>