Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to allow disabling read receipts #1150

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading