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.
This commit is contained in:
Bruno Windels 2020-09-23 19:11:11 +02:00
parent eb4237f6f4
commit ece4840653
2 changed files with 8 additions and 8 deletions

View file

@ -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,

View file

@ -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) {