diff options
author | Kegan Dougal <kegan@matrix.org> | 2014-11-14 11:13:03 +0000 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2014-11-14 11:13:03 +0000 |
commit | 974206ebe1a73a6d9c470b7f02bad74cb37d2e3c (patch) | |
tree | 55fa9eb15d7e7d0a631441b0429e9c01aba87c85 /syweb | |
parent | Add notification-service unit tests. (diff) | |
download | synapse-974206ebe1a73a6d9c470b7f02bad74cb37d2e3c.tar.xz |
Use mUserDisplayName filter in more places. Store power_level[norm] for each RoomMember.
Diffstat (limited to 'syweb')
-rw-r--r-- | syweb/webclient/components/matrix/model-service.js | 21 | ||||
-rw-r--r-- | syweb/webclient/room/room-controller.js | 22 |
2 files changed, 26 insertions, 17 deletions
diff --git a/syweb/webclient/components/matrix/model-service.js b/syweb/webclient/components/matrix/model-service.js index da71dac436..49cf5eff8c 100644 --- a/syweb/webclient/components/matrix/model-service.js +++ b/syweb/webclient/components/matrix/model-service.js @@ -121,6 +121,25 @@ angular.module('modelService', []) else if (event.type === "m.room.aliases") { setRoomIdToAliasMapping(event.room_id, event.content.aliases[0]); } + else if (event.type === "m.room.power_levels") { + // normalise power levels: find the max first. + var maxPowerLevel = 0; + for (var user_id in event.content) { + if (!event.content.hasOwnProperty(user_id)) continue; + maxPowerLevel = Math.max(maxPowerLevel, event.content[user_id]); + } + // set power level f.e room member + var defaultPowerLevel = event.content.default === undefined ? 0 : event.content.default; + for (var user_id in this.members) { + if (!this.members.hasOwnProperty(user_id)) continue; + var rm = this.members[user_id]; + if (!rm) { + continue; + } + rm.power_level = event.content[user_id] === undefined ? defaultPowerLevel : event.content[user_id]; + rm.power_level_norm = (rm.power_level * 100) / maxPowerLevel; + } + } }, storeStateEvents: function storeState(events) { @@ -140,6 +159,8 @@ angular.module('modelService', []) /***** Room Member Object *****/ var RoomMember = function RoomMember() { this.event = {}; // the m.room.member event representing the RoomMember. + this.power_level_norm = 0; + this.power_level = 0; this.user = undefined; // the User }; diff --git a/syweb/webclient/room/room-controller.js b/syweb/webclient/room/room-controller.js index 67372a804f..9a9381ed98 100644 --- a/syweb/webclient/room/room-controller.js +++ b/syweb/webclient/room/room-controller.js @@ -15,8 +15,8 @@ limitations under the License. */ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput', 'angular-peity']) -.controller('RoomController', ['$modal', '$filter', '$scope', '$timeout', '$routeParams', '$location', '$rootScope', 'matrixService', 'mPresence', 'eventHandlerService', 'mFileUpload', 'matrixPhoneService', 'MatrixCall', 'modelService', 'recentsService', 'commandsService', - function($modal, $filter, $scope, $timeout, $routeParams, $location, $rootScope, matrixService, mPresence, eventHandlerService, mFileUpload, matrixPhoneService, MatrixCall, modelService, recentsService, commandsService) { +.controller('RoomController', ['$modal', '$filter', '$scope', '$timeout', '$routeParams', '$location', '$rootScope', 'matrixService', 'mPresence', 'eventHandlerService', 'mFileUpload', 'matrixPhoneService', 'MatrixCall', 'modelService', 'recentsService', 'commandsService', 'mUserDisplayNameFilter', + function($modal, $filter, $scope, $timeout, $routeParams, $location, $rootScope, matrixService, mPresence, eventHandlerService, mFileUpload, matrixPhoneService, MatrixCall, modelService, recentsService, commandsService, mUserDisplayNameFilter) { 'use strict'; var MESSAGES_PER_PAGINATION = 30; var THUMBNAIL_SIZE = 320; @@ -162,24 +162,12 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput', 'a $scope.state.waiting_for_joined_event = false; onInit3(); } - else if (event.state_key === $scope.state.user_id && "invite" !== event.membership && "join" !== event.membership) { - var user; - - if ($scope.members[event.user_id]) { - user = $scope.members[event.user_id].displayname; - } - if (user) { - user = user + " (" + event.user_id + ")"; - } - else { - user = event.user_id; - } - + else if (event.state_key === $scope.state.user_id && "invite" !== event.membership && "join" !== event.membership) { if ("ban" === event.membership) { - $scope.state.permission_denied = "You have been banned by " + user; + $scope.state.permission_denied = "You have been banned by " + mUserDisplayNameFilter(event.user_id); } else { - $scope.state.permission_denied = "You have been kicked by " + user; + $scope.state.permission_denied = "You have been kicked by " + mUserDisplayNameFilter(event.user_id); } } else { |