diff options
author | Kegan Dougal <kegan@matrix.org> | 2014-11-14 16:15:32 +0000 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2014-11-14 16:15:32 +0000 |
commit | b93804529db45ab8bc5e320bdb9b34e9580e111a (patch) | |
tree | 976f187344f727b31b307c9bbe4d0ac84c87ce61 /syweb/webclient/components | |
parent | Fix bug which caused notifications to appear for old messages. (diff) | |
download | synapse-b93804529db45ab8bc5e320bdb9b34e9580e111a.tar.xz |
Move getUserPowerLevel to modelService.
Diffstat (limited to 'syweb/webclient/components')
-rw-r--r-- | syweb/webclient/components/matrix/event-handler-service.js | 21 | ||||
-rw-r--r-- | syweb/webclient/components/matrix/model-service.js | 24 |
2 files changed, 23 insertions, 22 deletions
diff --git a/syweb/webclient/components/matrix/event-handler-service.js b/syweb/webclient/components/matrix/event-handler-service.js index e9540bd5c0..8a32d06696 100644 --- a/syweb/webclient/components/matrix/event-handler-service.js +++ b/syweb/webclient/components/matrix/event-handler-service.js @@ -546,27 +546,6 @@ function(matrixService, $rootScope, $q, $timeout, $filter, mPresence, notificati } return memberCount; - }, - - /** - * Return the power level of an user in a particular room - * @param {String} room_id the room id - * @param {String} user_id the user id - * @returns {Number} a value between 0 and 10 - */ - getUserPowerLevel: function(room_id, user_id) { - var powerLevel = 0; - var room = modelService.getRoom(room_id).current_room_state; - if (room.state("m.room.power_levels")) { - if (user_id in room.state("m.room.power_levels").content) { - powerLevel = room.state("m.room.power_levels").content[user_id]; - } - else { - // Use the room default user power - powerLevel = room.state("m.room.power_levels").content["default"]; - } - } - return powerLevel; } }; }]); diff --git a/syweb/webclient/components/matrix/model-service.js b/syweb/webclient/components/matrix/model-service.js index e1fed65152..b4d59e7324 100644 --- a/syweb/webclient/components/matrix/model-service.js +++ b/syweb/webclient/components/matrix/model-service.js @@ -118,7 +118,8 @@ angular.module('modelService', []) }, storeStateEvent: function storeState(event) { - this.state_events[event.type + event.state_key] = event; + var keyIndex = event.state_key === undefined ? event.type : event.type + event.state_key; + this.state_events[keyIndex] = event; if (event.type === "m.room.member") { var userId = event.state_key; var rm = new RoomMember(); @@ -262,6 +263,27 @@ angular.module('modelService', []) rm.user = usr; } } + }, + + /** + * Return the power level of an user in a particular room + * @param {String} room_id the room id + * @param {String} user_id the user id + * @returns {Number} + */ + getUserPowerLevel: function(room_id, user_id) { + var powerLevel = 0; + var room = this.getRoom(room_id).current_room_state; + if (room.state("m.room.power_levels")) { + if (user_id in room.state("m.room.power_levels").content) { + powerLevel = room.state("m.room.power_levels").content[user_id]; + } + else { + // Use the room default user power + powerLevel = room.state("m.room.power_levels").content["default"]; + } + } + return powerLevel; } }; |