store room avatar url in summary

This commit is contained in:
Bruno Windels 2020-08-20 17:02:51 +02:00
parent 2241add672
commit da947fa0d0

View file

@ -46,15 +46,21 @@ function processEvent(data, event) {
} }
} }
if (event.type === "m.room.name") { if (event.type === "m.room.name") {
const newName = event.content && event.content.name; const newName = event.content?.name;
if (newName !== data.name) { if (newName !== data.name) {
data = data.cloneIfNeeded(); data = data.cloneIfNeeded();
data.name = newName; data.name = newName;
} }
} if (event.type === "m.room.avatar") {
const newUrl = event.content?.url;
if (newUrl !== data.avatarUrl) {
data = data.cloneIfNeeded();
data.avatarUrl = newUrl;
}
} else if (event.type === "m.room.message") { } else if (event.type === "m.room.message") {
const content = event.content; const {content} = event;
const body = content && content.body; const body = content?.body;
const msgtype = content && content.msgtype; const msgtype = content?.msgtype;
if (msgtype === "m.text") { if (msgtype === "m.text") {
data = data.cloneIfNeeded(); data = data.cloneIfNeeded();
data.lastMessageBody = body; data.lastMessageBody = body;
@ -105,6 +111,7 @@ class SummaryData {
this.altAliases = copy ? copy.altAliases : null; this.altAliases = copy ? copy.altAliases : null;
this.hasFetchedMembers = copy ? copy.hasFetchedMembers : false; this.hasFetchedMembers = copy ? copy.hasFetchedMembers : false;
this.lastPaginationToken = copy ? copy.lastPaginationToken : null; this.lastPaginationToken = copy ? copy.lastPaginationToken : null;
this.avatarUrl = copy ? copy.avatarUrl : null;
this.cloned = copy ? true : false; this.cloned = copy ? true : false;
} }
@ -155,6 +162,10 @@ export class RoomSummary {
return this._data.joinCount; return this._data.joinCount;
} }
get avatarUrl() {
return this._data.avatarUrl;
}
get hasFetchedMembers() { get hasFetchedMembers() {
return this._data.hasFetchedMembers; return this._data.hasFetchedMembers;
} }