BF: Update the members list on banned & kicked "events"

pull/10/head
Emmanuel ROHEE 2014-09-05 18:05:23 +02:00
parent 12a23f01b4
commit 8a7f7f5004
1 changed files with 13 additions and 4 deletions

View File

@ -175,16 +175,18 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
var updateMemberList = function(chunk) {
if (chunk.room_id != $scope.room_id) return;
// Ignore banned and kicked (leave) people
if ("ban" === chunk.membership || "leave" === chunk.membership) {
return;
}
// set target_user_id to keep things clear
var target_user_id = chunk.state_key;
var isNewMember = !(target_user_id in $scope.members);
if (isNewMember) {
// Ignore banned and kicked (leave) people
if ("ban" === chunk.membership || "leave" === chunk.membership) {
return;
}
// FIXME: why are we copying these fields around inside chunk?
if ("presence" in chunk.content) {
chunk.presence = chunk.content.presence;
@ -208,6 +210,13 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
}
else {
// selectively update membership and presence else it will nuke the picture and displayname too :/
// Remove banned and kicked (leave) people
if ("ban" === chunk.membership || "leave" === chunk.membership) {
delete $scope.members[target_user_id];
return;
}
var member = $scope.members[target_user_id];
member.membership = chunk.content.membership;
if ("presence" in chunk.content) {