diff options
-rw-r--r-- | webclient/components/matrix/event-handler-service.js | 16 | ||||
-rw-r--r-- | webclient/recents/recents-filter.js | 18 |
2 files changed, 29 insertions, 5 deletions
diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index 6fd77c4f29..4b0566fe33 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -398,6 +398,22 @@ angular.module('eventHandlerService', []) } 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; } }; }]); diff --git a/webclient/recents/recents-filter.js b/webclient/recents/recents-filter.js index 67fe49d4b6..2fd4dbe98b 100644 --- a/webclient/recents/recents-filter.js +++ b/webclient/recents/recents-filter.js @@ -17,19 +17,27 @@ 'use strict'; angular.module('RecentsController') -.filter('orderRecents', ["eventHandlerService", function(eventHandlerService) { +.filter('orderRecents', ["matrixService", "eventHandlerService", function(matrixService, eventHandlerService) { return function(rooms) { + var user_id = matrixService.config().user_id; + // Transform the dict into an array // The key, room_id, is already in value objects var filtered = []; angular.forEach(rooms, function(room, room_id) { - // Count users here - // TODO: Compute it directly in eventHandlerService - room.numUsersInRoom = eventHandlerService.getUsersCountInRoom(room_id); + // Show the room only if the user has joined it or has been invited + // (ie, do not show it if he has been banned) + var member = eventHandlerService.getMember(room_id, user_id); + if (member && ("invite" === member.membership || "join" === member.membership)) { + + // Count users here + // TODO: Compute it directly in eventHandlerService + room.numUsersInRoom = eventHandlerService.getUsersCountInRoom(room_id); - filtered.push(room); + filtered.push(room); + } }); // And time sort them |