diff --git a/src/domain/session/room/RoomViewModel.js b/src/domain/session/room/RoomViewModel.js index 1e2c9af61d..92dc78ee7b 100644 --- a/src/domain/session/room/RoomViewModel.js +++ b/src/domain/session/room/RoomViewModel.js @@ -33,6 +33,7 @@ export class RoomViewModel extends ErrorReportViewModel { constructor(options) { super(options); const {room, tileClassForEntry} = options; + this._sendReadReceipt = options.sendReadReceipt ?? true; this._room = room; this._timelineVM = null; this._tileClassForEntry = tileClassForEntry ?? defaultTileClassForEntry; @@ -127,7 +128,7 @@ export class RoomViewModel extends ErrorReportViewModel { this._clearUnreadTimout = this.clock.createTimeout(2000); try { await this._clearUnreadTimout.elapsed(); - await this._room.clearUnread(log); + await this._room.clearUnread(log, this._sendReadReceipt); this._clearUnreadTimout = null; } catch (err) { if (err.name === "AbortError") { diff --git a/src/matrix/room/Room.js b/src/matrix/room/Room.js index 73074f7a8e..ea8fe69028 100644 --- a/src/matrix/room/Room.js +++ b/src/matrix/room/Room.js @@ -430,7 +430,13 @@ export class Room extends BaseRoom { } } - async clearUnread(log = null) { + /** + * Clear the unreaad count in the room, and optionally send a read receipt + * @param {*} log Logger + * @param {boolean} sendReceipt Should a receipt be sent. + * @returns + */ + async clearUnread(log = null, sendReceipt = true) { if (this.isUnread || this.notificationCount) { return await this._platform.logger.wrapOrRun(log, "clearUnread", async log => { log.set("id", this.id); @@ -449,7 +455,7 @@ export class Room extends BaseRoom { this._emitUpdate(); try { - const lastEventId = await this._getLastEventId(); + const lastEventId = sendReceipt && await this._getLastEventId(); if (lastEventId) { await this._hsApi.receipt(this._roomId, "m.read", lastEventId); }