Correctly color archived and invited rooms

This commit is contained in:
Danila Fedorin 2021-06-29 16:50:42 -07:00
parent 6527a0c677
commit dec0683145
6 changed files with 24 additions and 5 deletions

View file

@ -56,7 +56,7 @@ export class InviteViewModel extends ViewModel {
}
get avatarColorNumber() {
return getIdentifierColorNumber(this._invite.id)
return getIdentifierColorNumber(this._invite.avatarColorId)
}
avatarUrl(size) {

View file

@ -107,6 +107,10 @@ export class ArchivedRoom extends BaseRoom {
this._emitUpdate();
}
get avatarColorId() {
return this._summary.data.avatarColorId;
}
get isKicked() {
return this._kickDetails?.membership === "leave";
}

View file

@ -341,6 +341,10 @@ export class BaseRoom extends EventEmitter {
return null;
}
get avatarColorId() {
return this._heroes?.roomAvatarColorId || this._roomId
}
get lastMessageTimestamp() {
return this._summary.data.lastMessageTimestamp;
}

View file

@ -56,6 +56,10 @@ export class Invite extends EventEmitter {
return this._inviteData.avatarUrl;
}
get avatarColorId() {
return this._inviteData.avatarColorId;
}
get timestamp() {
return this._inviteData.timestamp;
}
@ -175,6 +179,7 @@ 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,
@ -182,6 +187,7 @@ export class Invite extends EventEmitter {
// type:
name,
avatarUrl,
avatarColorId,
canonicalAlias: summaryData.canonicalAlias,
timestamp: this._platform.clock.now(),
joinRule: this._getJoinRule(inviteState),

View file

@ -328,10 +328,6 @@ export class Room extends BaseRoom {
});
}
get avatarColorId() {
return this._heroes?.roomAvatarColorId || this._roomId
}
get isUnread() {
return this._summary.data.isUnread;
}

View file

@ -239,6 +239,15 @@ export class SummaryData {
return !this.name && !this.canonicalAlias && this.heroes && this.heroes.length > 0;
}
get avatarColorId() {
if (this.heroes && this.heroes.length === 1) {
for (const hero of this.heroes) {
return hero;
}
}
return this.roomId;
}
isNewJoin(oldData) {
return this.membership === "join" && oldData.membership !== "join";
}