From d0f70cbdf9f3d9f1e29a3048106602cbabd9475c Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 29 Jun 2021 18:01:08 -0700 Subject: [PATCH] Move avatar color ID computation into SummaryData --- src/matrix/room/ArchivedRoom.js | 4 ---- src/matrix/room/BaseRoom.js | 2 +- src/matrix/room/Invite.js | 3 +-- src/matrix/room/members/Heroes.js | 9 --------- 4 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/matrix/room/ArchivedRoom.js b/src/matrix/room/ArchivedRoom.js index 97a92450..f975191e 100644 --- a/src/matrix/room/ArchivedRoom.js +++ b/src/matrix/room/ArchivedRoom.js @@ -107,10 +107,6 @@ export class ArchivedRoom extends BaseRoom { this._emitUpdate(); } - get avatarColorId() { - return this._summary.data.avatarColorId; - } - get isKicked() { return this._kickDetails?.membership === "leave"; } diff --git a/src/matrix/room/BaseRoom.js b/src/matrix/room/BaseRoom.js index 7d8bf040..70fe5663 100644 --- a/src/matrix/room/BaseRoom.js +++ b/src/matrix/room/BaseRoom.js @@ -342,7 +342,7 @@ export class BaseRoom extends EventEmitter { } get avatarColorId() { - return this._heroes?.roomAvatarColorId || this._roomId + return this._summary.data.avatarColorId; } get lastMessageTimestamp() { diff --git a/src/matrix/room/Invite.js b/src/matrix/room/Invite.js index a0391a12..7346298b 100644 --- a/src/matrix/room/Invite.js +++ b/src/matrix/room/Invite.js @@ -179,7 +179,6 @@ export class Invite extends EventEmitter { _createData(inviteState, myInvite, inviter, summaryData, heroes) { const name = heroes ? heroes.roomName : summaryData.name; const avatarUrl = heroes ? heroes.roomAvatarUrl : summaryData.avatarUrl; - const avatarColorId = heroes ? heroes.roomAvatarColorId : summaryData.avatarColorId; return { roomId: this.id, isEncrypted: !!summaryData.encryption, @@ -187,7 +186,7 @@ export class Invite extends EventEmitter { // type: name, avatarUrl, - avatarColorId, + avatarColorId: summaryData.avatarColorId, canonicalAlias: summaryData.canonicalAlias, timestamp: this._platform.clock.now(), joinRule: this._getJoinRule(inviteState), diff --git a/src/matrix/room/members/Heroes.js b/src/matrix/room/members/Heroes.js index 6336cda2..f6ad3085 100644 --- a/src/matrix/room/members/Heroes.js +++ b/src/matrix/room/members/Heroes.js @@ -97,13 +97,4 @@ export class Heroes { } return null; } - - get roomAvatarColorId() { - if (this._members.size === 1) { - for (const member of this._members.values()) { - return member.userId; - } - } - return null; - } }