mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-11-20 03:25:52 +01:00
Merge pull request #1150 from vector-im/hs/allow-disabling-read-receipts-in-sdk
Add option to allow disabling read receipts
This commit is contained in:
commit
145189f957
@ -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") {
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user