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));
@@ -1323,7 +1327,7 @@ function calculateRoomName(room, userId, ignoreRoomNameEvent) {
if (myMembership == 'join') { if (myMembership == 'join') {
const thirdPartyInvites = const thirdPartyInvites =
room.currentState.getStateEvents("m.room.third_party_invite"); room.currentState.getStateEvents("m.room.third_party_invite");
if (thirdPartyInvites && thirdPartyInvites.length) { if (thirdPartyInvites && thirdPartyInvites.length) {
const thirdPartyNames = thirdPartyInvites.map((i) => { const thirdPartyNames = thirdPartyInvites.map((i) => {
return {name: i.getContent().display_name}; return {name: i.getContent().display_name};
@@ -1344,17 +1348,16 @@ 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";
} }
} }
function memberListToRoomName(members, count = members.length) { function memberListToRoomName(members, count = members.length) {
switch (members.length) { switch (members.length) {
case 0: return null; case 0: return null;
case 1: return members[0].name; case 1: return members[0].name;
case 2: return members[0].name + " and " + members[1].name; case 2: return members[0].name + " and " + members[1].name;
default: return members[0].name + " and " + (count - 1) + " others"; default: return members[0].name + " and " + (count - 1) + " others";
} }
} }

View File

@@ -268,7 +268,7 @@ class SyncAccumulator {
const HEROES_KEY = "m.heroes"; const HEROES_KEY = "m.heroes";
const INVITED_COUNT_KEY = "m.invited_member_count"; const INVITED_COUNT_KEY = "m.invited_member_count";
const JOINED_COUNT_KEY = "m.joined_member_count"; const JOINED_COUNT_KEY = "m.joined_member_count";
const acc = currentData._summary; const acc = currentData._summary;
const sum = data.summary; const sum = data.summary;
acc[HEROES_KEY] = sum[HEROES_KEY] || acc[HEROES_KEY]; acc[HEROES_KEY] = sum[HEROES_KEY] || acc[HEROES_KEY];

View File

@@ -1067,7 +1067,7 @@ SyncApi.prototype._processSyncResponse = async function(
if (joinObj.summary) { if (joinObj.summary) {
room.setSummary(joinObj.summary); room.setSummary(joinObj.summary);
} }
// XXX: should we be adding ephemeralEvents to the timeline? // XXX: should we be adding ephemeralEvents to the timeline?
// It feels like that for symmetry with room.addAccountData() // It feels like that for symmetry with room.addAccountData()
// there should be a room.addEphemeralEvents() or similar. // there should be a room.addEphemeralEvents() or similar.