Skip to content

Commit

Permalink
Add option to allow disabling read receipts
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed Nov 7, 2023
1 parent bf7c2fe commit 7b35a25
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/domain/session/room/RoomViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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") {
Expand Down
10 changes: 8 additions & 2 deletions src/matrix/room/Room.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down

0 comments on commit 7b35a25

Please sign in to comment.