0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-11-03 05:08:59 +01:00

Filter room where the user has been banned

This commit is contained in:
Emmanuel ROHEE 2014-09-15 18:22:38 +02:00
parent 8aa4b7bf7f
commit b0483cd47d
2 changed files with 29 additions and 5 deletions

View file

@ -398,6 +398,22 @@ angular.module('eventHandlerService', [])
} }
return memberCount; return memberCount;
},
/**
* Get the member object of a room member
* @param {String} room_id the room id
* @param {String} user_id the id of the user
* @returns {undefined | Object} the member object of this user in this room if he is part of the room
*/
getMember: function(room_id, user_id) {
var member;
var room = $rootScope.events.rooms[room_id];
if (room) {
member = room.members[user_id];
}
return member;
} }
}; };
}]); }]);

View file

@ -17,19 +17,27 @@
'use strict'; 'use strict';
angular.module('RecentsController') angular.module('RecentsController')
.filter('orderRecents', ["eventHandlerService", function(eventHandlerService) { .filter('orderRecents', ["matrixService", "eventHandlerService", function(matrixService, eventHandlerService) {
return function(rooms) { return function(rooms) {
var user_id = matrixService.config().user_id;
// Transform the dict into an array // Transform the dict into an array
// The key, room_id, is already in value objects // The key, room_id, is already in value objects
var filtered = []; var filtered = [];
angular.forEach(rooms, function(room, room_id) { angular.forEach(rooms, function(room, room_id) {
// Count users here // Show the room only if the user has joined it or has been invited
// TODO: Compute it directly in eventHandlerService // (ie, do not show it if he has been banned)
room.numUsersInRoom = eventHandlerService.getUsersCountInRoom(room_id); var member = eventHandlerService.getMember(room_id, user_id);
if (member && ("invite" === member.membership || "join" === member.membership)) {
filtered.push(room); // Count users here
// TODO: Compute it directly in eventHandlerService
room.numUsersInRoom = eventHandlerService.getUsersCountInRoom(room_id);
filtered.push(room);
}
}); });
// And time sort them // And time sort them