summary refs log tree commit diff
path: root/webclient/room/room-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'webclient/room/room-controller.js')
-rw-r--r--webclient/room/room-controller.js48
1 files changed, 14 insertions, 34 deletions
diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js
index 09dac85d26..ed7de62c08 100644
--- a/webclient/room/room-controller.js
+++ b/webclient/room/room-controller.js
@@ -88,7 +88,7 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
         call.onHangup = $scope.onCallHangup;
         $scope.currentCall = call;
     });
-
+    
     $scope.memberCount = function() {
         return Object.keys($scope.members).length;
     };
@@ -175,6 +175,8 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
 
         // set target_user_id to keep things clear
         var target_user_id = chunk.state_key;
+        
+        var now = new Date().getTime();
 
         var isNewMember = !(target_user_id in $scope.members);
         if (isNewMember) {
@@ -185,44 +187,14 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
             if ("mtime_age" in chunk.content) {
                 chunk.mtime_age = chunk.content.mtime_age;
             }
-            // Once the HS reliably returns the displaynames & avatar_urls for both
-            // local and remote users, we should use this rather than the evalAsync block
-            // below
             if ("displayname" in chunk.content) {
                 chunk.displayname = chunk.content.displayname;
             }
             if ("avatar_url" in chunk.content) {
                 chunk.avatar_url = chunk.content.avatar_url;
             }
-            $scope.members[target_user_id] = chunk;
-
-/*
-            // Stale code for explicitly hammering the homeserver for every displayname & avatar_url
-            
-            // get their display name and profile picture and set it to their
-            // member entry in $scope.members. We HAVE to use $timeout with 0 delay 
-            // to make this function run AFTER the current digest cycle, else the 
-            // response may update a STALE VERSION of the member list (manifesting
-            // as no member names appearing, or appearing sporadically).
-            $scope.$evalAsync(function() {
-                matrixService.getDisplayName(chunk.target_user_id).then(
-                    function(response) {
-                        var member = $scope.members[chunk.target_user_id];
-                        if (member !== undefined) {
-                            member.displayname = response.data.displayname;
-                        }
-                    }
-                ); 
-                matrixService.getProfilePictureUrl(chunk.target_user_id).then(
-                    function(response) {
-                         var member = $scope.members[chunk.target_user_id];
-                         if (member !== undefined) {
-                            member.avatar_url = response.data.avatar_url;
-                         }
-                    }
-                );
-            });
-*/            
+            chunk.last_updated = now;
+            $scope.members[target_user_id] = chunk;   
 
             if (target_user_id in $rootScope.presence) {
                 updatePresence($rootScope.presence[target_user_id]);
@@ -234,6 +206,12 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
             member.content.membership = chunk.content.membership;
         }
     };
+    
+    var updateMemberListPresenceAge = function() {
+        $scope.now = new Date().getTime();
+        //console.log("updateMemberListPresenceAge() - now = " + $scope.now);
+        $timeout(updateMemberListPresenceAge, 5 * 1000);
+    };
 
     var updatePresence = function(chunk) {
         if (!(chunk.content.user_id in $scope.members)) {
@@ -395,8 +373,10 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
 
         // Make recents highlight the current room
         $scope.recentsSelectedRoomID = $scope.room_id;
-        
+                
         paginate(MESSAGES_PER_PAGINATION);
+        
+        updateMemberListPresenceAge();
     }; 
     
     $scope.inviteUser = function(user_id) {