summary refs log tree commit diff
path: root/webclient
diff options
context:
space:
mode:
authorMatthew Hodgson <matthew@matrix.org>2014-08-16 20:48:05 +0100
committerMatthew Hodgson <matthew@matrix.org>2014-08-16 20:48:05 +0100
commitfe25e65f3f6c4bce9b61c8136cbd0585455321a3 (patch)
tree0761665bc8ab3d59473e81d50825dbd5c91e6df1 /webclient
parentmake presence timestamps less verbose (diff)
downloadsynapse-fe25e65f3f6c4bce9b61c8136cbd0585455321a3.tar.xz
disambiguate identical displaynames
Diffstat (limited to 'webclient')
-rw-r--r--webclient/app.js24
1 files changed, 23 insertions, 1 deletions
diff --git a/webclient/app.js b/webclient/app.js
index f6ce69e403..a6668da6eb 100644
--- a/webclient/app.js
+++ b/webclient/app.js
@@ -117,12 +117,34 @@ matrixWebClient
     .filter('orderMembersList', function($sce) {
         return function(members) {
             var filtered = [];
+            
+            var displayNames = {};
             angular.forEach(members, function(value, key) {
                 value["id"] = key;
                 filtered.push( value );
+                if (value["displayname"]) {
+                    if (!displayNames[value["displayname"]]) {
+                        displayNames[value["displayname"]] = [];
+                    }
+                    displayNames[value["displayname"]].push(key);
+                }
             });
+
+            // FIXME: we shouldn't disambiguate displayNames on every orderMembersList
+            // invocation but keep track of duplicates incrementally somewhere            
+            angular.forEach(displayNames, function(value, key) {
+                if (value.length > 1) {
+                    console.log(key + ": " + value);
+                    for (i=0; i < value.length; i++) {
+                        var v = value[i];
+                        members[v].displayname += " (" + v + ")";
+                        console.log(v + " " + members[v]);
+                    };
+                }
+            });
+            
             filtered.sort(function (a, b) {
-                return ((a["mtime_age"] || 10e10)> (b["mtime_age"] || 10e10) ? 1 : -1);
+                return ((a["mtime_age"] || 10e10) > (b["mtime_age"] || 10e10) ? 1 : -1);
             });
             return filtered;
         };