1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-29 16:43:09 +03:00
This commit is contained in:
Bruno Windels
2018-07-25 18:45:52 +02:00
parent e61c6b89c8
commit 9541aa7dbf
4 changed files with 17 additions and 14 deletions

View File

@@ -110,7 +110,7 @@ RoomState.prototype.getJoinedMemberCount = function() {
*/ */
RoomState.prototype.setJoinedMemberCount = function(count) { RoomState.prototype.setJoinedMemberCount = function(count) {
this._joinedMemberCount = count; this._joinedMemberCount = count;
} };
/** /**
* Returns the number of invited members in this room * Returns the number of invited members in this room
* @return {integer} The number of members in this room whose membership is 'invite' * @return {integer} The number of members in this room whose membership is 'invite'
@@ -130,7 +130,7 @@ RoomState.prototype.getInvitedMemberCount = function() {
*/ */
RoomState.prototype.setInvitedMemberCount = function(count) { RoomState.prototype.setInvitedMemberCount = function(count) {
this._invitedMemberCount = count; this._invitedMemberCount = count;
} };
/** /**
* Get all RoomMembers in this room. * Get all RoomMembers in this room.

View File

@@ -391,7 +391,7 @@ Room.prototype.setSummary = function(summary) {
if (heroes) { if (heroes) {
this._summaryHeroes = heroes; this._summaryHeroes = heroes;
} }
} };
/** /**
* Whether to send encrypted messages to devices within this room. * Whether to send encrypted messages to devices within this room.
@@ -1301,11 +1301,15 @@ function calculateRoomName(room, userId, ignoreRoomNameEvent) {
// get members that are NOT ourselves and are actually in the room. // get members that are NOT ourselves and are actually in the room.
let otherMembers = null; let otherMembers = null;
if (room._summaryHeroes) { if (room._summaryHeroes) {
// if we have a summary, the member state events should have been in the room state // if we have a summary, the member state events
otherMembers = room._summaryHeroes.map((userId) => room.currentState.getMember(userId)); // should be in the room state
otherMembers = room._summaryHeroes.map((userId) => {
return room.currentState.getMember(userId);
});
} else { } else {
otherMembers = room.currentState.getMembers().filter((m) => { otherMembers = room.currentState.getMembers().filter((m) => {
return m.userId !== userId && (m.membership === "invite" || m.membership === "join"); return m.userId !== userId &&
(m.membership === "invite" || m.membership === "join");
}); });
// make sure members have stable order // make sure members have stable order
otherMembers.sort((a, b) => a.userId.localeCompare(b.userId)); otherMembers.sort((a, b) => a.userId.localeCompare(b.userId));
@@ -1344,8 +1348,7 @@ function calculateRoomName(room, userId, ignoreRoomNameEvent) {
} }
if(leftMembers.length) { if(leftMembers.length) {
return `Empty room (was ${memberListToRoomName(leftMembers)})`; return `Empty room (was ${memberListToRoomName(leftMembers)})`;
} } else {
else {
return "Empty room"; return "Empty room";
} }
} }