From ece4840653ce2c428cf83be6c11c1cdd47a6c564 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 23 Sep 2020 19:11:11 +0200 Subject: [PATCH] don't mark rooms as unread after retrying decryption for now this will not mark e2ee rooms as unread if their room key is delayed though. We should really only do this for back-filled events but that is hard to do right now, as we don't know the original source here. --- src/matrix/room/Room.js | 4 ++-- src/matrix/room/RoomSummary.js | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/matrix/room/Room.js b/src/matrix/room/Room.js index 40173c3c..369836ee 100644 --- a/src/matrix/room/Room.js +++ b/src/matrix/room/Room.js @@ -114,7 +114,7 @@ export class Room extends EventEmitter { // _decryptEntries entries and could even know which events have been decrypted for the first // time from DecryptionChanges.write and only pass those to the summary. As timeline changes // are not essential to the room summary, it's fine to write this in a separate txn for now. - const changes = this._summary.data.applyTimelineEntries(retryEntries, false, this._isTimelineOpen); + const changes = this._summary.data.applyTimelineEntries(retryEntries, false, false); if (await this._summary.writeAndApplyData(changes, this._storage)) { this._emitUpdate(); } @@ -218,7 +218,7 @@ export class Room extends EventEmitter { } // also apply (decrypted) timeline entries to the summary changes summaryChanges = summaryChanges.applyTimelineEntries( - entries, isInitialSync, this._isTimelineOpen, this._user.id); + entries, isInitialSync, !this._isTimelineOpen, this._user.id); // write summary changes, and unset if nothing was actually changed summaryChanges = this._summary.writeData(summaryChanges, txn); // fetch new members while we have txn open, diff --git a/src/matrix/room/RoomSummary.js b/src/matrix/room/RoomSummary.js index b4826fa3..c708ee91 100644 --- a/src/matrix/room/RoomSummary.js +++ b/src/matrix/room/RoomSummary.js @@ -17,11 +17,11 @@ limitations under the License. import {MEGOLM_ALGORITHM} from "../e2ee/common.js"; -function applyTimelineEntries(data, timelineEntries, isInitialSync, isTimelineOpen, ownUserId) { +function applyTimelineEntries(data, timelineEntries, isInitialSync, canMarkUnread, ownUserId) { if (timelineEntries.length) { data = timelineEntries.reduce((data, entry) => { return processTimelineEvent(data, entry, - isInitialSync, isTimelineOpen, ownUserId); + isInitialSync, canMarkUnread, ownUserId); }, data); } return data; @@ -105,13 +105,13 @@ function processStateEvent(data, event) { return data; } -function processTimelineEvent(data, eventEntry, isInitialSync, isTimelineOpen, ownUserId) { +function processTimelineEvent(data, eventEntry, isInitialSync, canMarkUnread, ownUserId) { if (eventEntry.eventType === "m.room.message") { if (!data.lastMessageTimestamp || eventEntry.timestamp > data.lastMessageTimestamp) { data = data.cloneIfNeeded(); data.lastMessageTimestamp = eventEntry.timestamp; } - if (!isInitialSync && eventEntry.sender !== ownUserId && !isTimelineOpen) { + if (!isInitialSync && eventEntry.sender !== ownUserId && canMarkUnread) { data = data.cloneIfNeeded(); data.isUnread = true; } @@ -208,8 +208,8 @@ class SummaryData { return serializedProps; } - applyTimelineEntries(timelineEntries, isInitialSync, isTimelineOpen, ownUserId) { - return applyTimelineEntries(this, timelineEntries, isInitialSync, isTimelineOpen, ownUserId); + applyTimelineEntries(timelineEntries, isInitialSync, canMarkUnread, ownUserId) { + return applyTimelineEntries(this, timelineEntries, isInitialSync, canMarkUnread, ownUserId); } applySyncResponse(roomResponse, membership) {