store isUnread and lastMessageTimestamp

This commit is contained in:
Bruno Windels 2020-08-21 11:55:47 +02:00
parent 53720f56df
commit 4419b3366e

View file

@ -63,11 +63,13 @@ function processEvent(data, event) {
data.avatarUrl = newUrl; data.avatarUrl = newUrl;
} }
} else if (event.type === "m.room.message") { } else if (event.type === "m.room.message") {
data = data.cloneIfNeeded();
data.lastMessageTimestamp = event.origin_server_ts;
data.isUnread = true;
const {content} = event; const {content} = event;
const body = content?.body; const body = content?.body;
const msgtype = content?.msgtype; const msgtype = content?.msgtype;
if (msgtype === "m.text") { if (msgtype === "m.text") {
data = data.cloneIfNeeded();
data.lastMessageBody = body; data.lastMessageBody = body;
} }
} else if (event.type === "m.room.canonical_alias") { } else if (event.type === "m.room.canonical_alias") {
@ -104,8 +106,8 @@ class SummaryData {
this.roomId = copy ? copy.roomId : roomId; this.roomId = copy ? copy.roomId : roomId;
this.name = copy ? copy.name : null; this.name = copy ? copy.name : null;
this.lastMessageBody = copy ? copy.lastMessageBody : null; this.lastMessageBody = copy ? copy.lastMessageBody : null;
this.unreadCount = copy ? copy.unreadCount : null; this.lastMessageTimestamp = copy ? copy.lastMessageTimestamp : null;
this.mentionCount = copy ? copy.mentionCount : null; this.isUnread = copy ? copy.isUnread : null;
this.isEncrypted = copy ? copy.isEncrypted : null; this.isEncrypted = copy ? copy.isEncrypted : null;
this.isDirectMessage = copy ? copy.isDirectMessage : null; this.isDirectMessage = copy ? copy.isDirectMessage : null;
this.membership = copy ? copy.membership : null; this.membership = copy ? copy.membership : null;
@ -157,10 +159,18 @@ export class RoomSummary {
return this._data.roomId; return this._data.roomId;
} }
get isUnread() {
return this._data.isUnread;
}
get lastMessage() { get lastMessage() {
return this._data.lastMessageBody; return this._data.lastMessageBody;
} }
get lastMessageTimestamp() {
return this._data.lastMessageTimestamp;
}
get inviteCount() { get inviteCount() {
return this._data.inviteCount; return this._data.inviteCount;
} }