From 4419b3366e5294ccc581e064ff5aa18b58fefbf8 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 21 Aug 2020 11:55:47 +0200 Subject: [PATCH] store isUnread and lastMessageTimestamp --- src/matrix/room/RoomSummary.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/matrix/room/RoomSummary.js b/src/matrix/room/RoomSummary.js index a674d9e2..bb74656f 100644 --- a/src/matrix/room/RoomSummary.js +++ b/src/matrix/room/RoomSummary.js @@ -63,11 +63,13 @@ function processEvent(data, event) { data.avatarUrl = newUrl; } } else if (event.type === "m.room.message") { + data = data.cloneIfNeeded(); + data.lastMessageTimestamp = event.origin_server_ts; + data.isUnread = true; const {content} = event; const body = content?.body; const msgtype = content?.msgtype; if (msgtype === "m.text") { - data = data.cloneIfNeeded(); data.lastMessageBody = body; } } else if (event.type === "m.room.canonical_alias") { @@ -104,8 +106,8 @@ class SummaryData { this.roomId = copy ? copy.roomId : roomId; this.name = copy ? copy.name : null; this.lastMessageBody = copy ? copy.lastMessageBody : null; - this.unreadCount = copy ? copy.unreadCount : null; - this.mentionCount = copy ? copy.mentionCount : null; + this.lastMessageTimestamp = copy ? copy.lastMessageTimestamp : null; + this.isUnread = copy ? copy.isUnread : null; this.isEncrypted = copy ? copy.isEncrypted : null; this.isDirectMessage = copy ? copy.isDirectMessage : null; this.membership = copy ? copy.membership : null; @@ -157,10 +159,18 @@ export class RoomSummary { return this._data.roomId; } + get isUnread() { + return this._data.isUnread; + } + get lastMessage() { return this._data.lastMessageBody; } + get lastMessageTimestamp() { + return this._data.lastMessageTimestamp; + } + get inviteCount() { return this._data.inviteCount; }