summary refs log tree commit diff
path: root/syweb
diff options
context:
space:
mode:
Diffstat (limited to 'syweb')
-rw-r--r--syweb/webclient/components/matrix/model-service.js3
-rw-r--r--syweb/webclient/room/room-controller.js45
-rw-r--r--syweb/webclient/room/room.html4
3 files changed, 4 insertions, 48 deletions
diff --git a/syweb/webclient/components/matrix/model-service.js b/syweb/webclient/components/matrix/model-service.js
index 49cf5eff8c..7d7a61cbf8 100644
--- a/syweb/webclient/components/matrix/model-service.js
+++ b/syweb/webclient/components/matrix/model-service.js
@@ -41,6 +41,7 @@ angular.module('modelService', [])
         this.room_id = room_id;
         this.old_room_state = new RoomState();
         this.current_room_state = new RoomState();
+        this.now = this.current_room_state; // makes html access shorter
         this.events = []; // events which can be displayed on the UI. TODO move?
     };
     Room.prototype = {
@@ -125,7 +126,7 @@ angular.module('modelService', [])
                 // normalise power levels: find the max first.
                 var maxPowerLevel = 0;
                 for (var user_id in event.content) {
-                    if (!event.content.hasOwnProperty(user_id)) continue;
+                    if (!event.content.hasOwnProperty(user_id) || user_id === "hsob_ts") continue; // XXX hsob_ts on some old rooms :(
                     maxPowerLevel = Math.max(maxPowerLevel, event.content[user_id]);
                 }
                 // set power level f.e room member
diff --git a/syweb/webclient/room/room-controller.js b/syweb/webclient/room/room-controller.js
index 9a9381ed98..83ed595966 100644
--- a/syweb/webclient/room/room-controller.js
+++ b/syweb/webclient/room/room-controller.js
@@ -182,14 +182,6 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput', 'a
             updatePresence(event);
         }
     });
-    
-    $scope.$on(eventHandlerService.POWERLEVEL_EVENT, function(ngEvent, event, isLive) {
-        if (isLive && event.room_id === $scope.room_id) {
-            for (var user_id in event.content) {
-                updateUserPowerLevel(user_id);
-            }
-        }
-    });
 
     $scope.memberCount = function() {
         return Object.keys($scope.members).length;
@@ -359,40 +351,6 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput', 'a
         }
     };
 
-    var updateUserPowerLevel = function(user_id) {
-        var member = $scope.members[user_id];
-        if (member) {
-            member.powerLevel = eventHandlerService.getUserPowerLevel($scope.room_id, user_id);
-            
-            normaliseMembersPowerLevels();
-        }
-    };
-
-    // Normalise users power levels so that the user with the higher power level
-    // will have a bar covering 100% of the width of his avatar
-    var normaliseMembersPowerLevels = function() {
-        // Find the max power level
-        var maxPowerLevel = 0;
-        for (var i in $scope.members) {
-            if (!$scope.members.hasOwnProperty(i)) continue;
-
-            var member = $scope.members[i];
-            if (member.powerLevel) {
-                maxPowerLevel = Math.max(maxPowerLevel, member.powerLevel);
-            }
-        }
-
-        // Normalized them on a 0..100% scale to be use in css width
-        if (maxPowerLevel) {
-            for (var i in $scope.members) {
-                if (!$scope.members.hasOwnProperty(i)) continue;
-
-                var member = $scope.members[i];
-                member.powerLevelNorm = (member.powerLevel * 100) / maxPowerLevel;
-            }
-        }
-    };
-
     $scope.send = function() {
         var input = $('#mainInput').val();
         
@@ -621,9 +579,6 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput', 'a
                 for (var i = 0; i < response.data.chunk.length; i++) {
                     var chunk = response.data.chunk[i];
                     updateMemberList(chunk);
-
-                    // Add his power level
-                    updateUserPowerLevel(chunk.user_id);
                 }
 
                 // Arm list timing update timer
diff --git a/syweb/webclient/room/room.html b/syweb/webclient/room/room.html
index 17565f879b..ee7c9777a9 100644
--- a/syweb/webclient/room/room.html
+++ b/syweb/webclient/room/room.html
@@ -132,12 +132,12 @@
                      ng-click="$parent.goToUserPage(member.id)"
                      ng-src="{{member.avatar_url || 'img/default-profile.png'}}" 
                      alt="{{ member.displayname || member.id.substr(0, member.id.indexOf(':')) }}"
-                     title="{{ member.id }} - power: {{ member.powerLevel }}"
+                     title="{{ member.id }} - power: {{ room.now.members[member.id].power_level }}"
                      width="80" height="80"/>
                 <!-- <div class="userPowerLevel" ng-style="{'width': member.powerLevelNorm +'%'}"></div> -->
             </div>
             <div class="userName">
-                <pie-chart ng-show="member.powerLevelNorm" data="[ (member.powerLevelNorm + 0), (100 - member.powerLevelNorm) ]"></pie-chart>
+                <pie-chart ng-show="room.now.members[member.id].power_level_norm" data="[ (room.now.members[member.id].power_level_norm + 0), (100 - room.now.members[member.id].power_level_norm) ]"></pie-chart>
                 {{ member.id | mUserDisplayName:room_id:true }}
                 <span ng-show="member.last_active_ago" style="color: #aaa">({{ member.last_active_ago + (now - member.last_updated) | duration }})</span>
             </div>