Added hasOwnProperty tests when required to be robust to random properties added to he Object prototype
This commit is contained in:
parent
ef5b39c410
commit
6f5970a2e1
3 changed files with 12 additions and 1 deletions
|
@ -115,8 +115,9 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) {
|
|||
|
||||
if (room) { // we got an existing room object from initialsync, seemingly.
|
||||
// Report all other metadata of the room object (membership, inviter, visibility, ...)
|
||||
// XXX: do we *REALLY* want to iterate over *EVERY* field in the object, including all its methods etc? -- Matthew
|
||||
for (var field in room) {
|
||||
if (!room.hasOwnProperty(field)) continue;
|
||||
|
||||
if (-1 === ["room_id", "messages", "state"].indexOf(field)) { // why indexOf - why not ===? --Matthew
|
||||
$rootScope.events.rooms[room_id][field] = room[field];
|
||||
}
|
||||
|
@ -517,6 +518,8 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) {
|
|||
memberCount = 0;
|
||||
|
||||
for (var i in room.members) {
|
||||
if (!room.members.hasOwnProperty(i)) continue;
|
||||
|
||||
var member = room.members[i];
|
||||
|
||||
if ("join" === member.membership) {
|
||||
|
|
|
@ -45,6 +45,8 @@ angular.module('matrixFilter', [])
|
|||
// Limit the room renaming to 1:1 room
|
||||
if (2 === Object.keys(room.members).length) {
|
||||
for (var i in room.members) {
|
||||
if (!room.members.hasOwnProperty(i)) continue;
|
||||
|
||||
var member = room.members[i];
|
||||
if (member.state_key !== user_id) {
|
||||
roomName = eventHandlerService.getUserDisplayName(room_id, member.state_key);
|
||||
|
|
|
@ -400,6 +400,8 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
|
|||
// 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);
|
||||
|
@ -409,6 +411,8 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
|
|||
// 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;
|
||||
}
|
||||
|
@ -724,6 +728,8 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
|
|||
|
||||
// Update the member list
|
||||
for (var i in members) {
|
||||
if (!members.hasOwnProperty(i)) continue;
|
||||
|
||||
var member = members[i];
|
||||
updateMemberList(member);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue