forked from MirrorHub/synapse
Use mUserDisplayName filter in more places. Store power_level[norm] for each RoomMember.
This commit is contained in:
parent
687662c990
commit
974206ebe1
2 changed files with 26 additions and 17 deletions
|
@ -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
|
||||
};
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue