From 97854423c4efd74a296208b4a653ecc1c0fa424b Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Mon, 28 Jun 2021 11:44:27 -0700 Subject: [PATCH] Ensure DM rooms have the same color in timeline and left panel. --- src/domain/session/rightpanel/RoomDetailsViewModel.js | 2 +- src/domain/session/room/RoomViewModel.js | 2 +- src/matrix/room/Room.js | 4 ++++ src/matrix/room/members/Heroes.js | 9 +++++++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/domain/session/rightpanel/RoomDetailsViewModel.js b/src/domain/session/rightpanel/RoomDetailsViewModel.js index 911e5945..b9f05835 100644 --- a/src/domain/session/rightpanel/RoomDetailsViewModel.js +++ b/src/domain/session/rightpanel/RoomDetailsViewModel.js @@ -34,7 +34,7 @@ export class RoomDetailsViewModel extends ViewModel { } get avatarColorNumber() { - return getIdentifierColorNumber(this.roomId) + return getIdentifierColorNumber(this._room.avatarColorId) } avatarUrl(size) { diff --git a/src/domain/session/room/RoomViewModel.js b/src/domain/session/room/RoomViewModel.js index 4d53ec6c..38835db3 100644 --- a/src/domain/session/room/RoomViewModel.js +++ b/src/domain/session/room/RoomViewModel.js @@ -119,7 +119,7 @@ export class RoomViewModel extends ViewModel { } get avatarColorNumber() { - return getIdentifierColorNumber(this._room.id) + return getIdentifierColorNumber(this._room.avatarColorId) } avatarUrl(size) { diff --git a/src/matrix/room/Room.js b/src/matrix/room/Room.js index 482d167f..5e002411 100644 --- a/src/matrix/room/Room.js +++ b/src/matrix/room/Room.js @@ -328,6 +328,10 @@ export class Room extends BaseRoom { }); } + get avatarColorId() { + return this._heroes?.roomAvatarColorId || this._roomId + } + get isUnread() { return this._summary.data.isUnread; } diff --git a/src/matrix/room/members/Heroes.js b/src/matrix/room/members/Heroes.js index f6ad3085..6336cda2 100644 --- a/src/matrix/room/members/Heroes.js +++ b/src/matrix/room/members/Heroes.js @@ -97,4 +97,13 @@ export class Heroes { } return null; } + + get roomAvatarColorId() { + if (this._members.size === 1) { + for (const member of this._members.values()) { + return member.userId; + } + } + return null; + } }