mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
log clearing unread state of a room
This commit is contained in:
parent
376e59820c
commit
48c361531d
@ -548,33 +548,36 @@ export class Room extends EventEmitter {
|
|||||||
this._emitCollectionChange(this);
|
this._emitCollectionChange(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
async clearUnread() {
|
async clearUnread(log = null) {
|
||||||
if (this.isUnread || this.notificationCount) {
|
if (this.isUnread || this.notificationCount) {
|
||||||
const txn = this._storage.readWriteTxn([
|
return await this._platform.logger.wrapOrRun(log, "clearUnread", async log => {
|
||||||
this._storage.storeNames.roomSummary,
|
log.set("id", this.id);
|
||||||
]);
|
const txn = this._storage.readWriteTxn([
|
||||||
let data;
|
this._storage.storeNames.roomSummary,
|
||||||
try {
|
]);
|
||||||
data = this._summary.writeClearUnread(txn);
|
let data;
|
||||||
} catch (err) {
|
try {
|
||||||
txn.abort();
|
data = this._summary.writeClearUnread(txn);
|
||||||
throw err;
|
} catch (err) {
|
||||||
}
|
txn.abort();
|
||||||
await txn.complete();
|
|
||||||
this._summary.applyChanges(data);
|
|
||||||
this._emitUpdate();
|
|
||||||
|
|
||||||
try {
|
|
||||||
const lastEventId = await this._getLastEventId();
|
|
||||||
if (lastEventId) {
|
|
||||||
await this._hsApi.receipt(this._roomId, "m.read", lastEventId);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
// ignore ConnectionError
|
|
||||||
if (err.name !== "ConnectionError") {
|
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
await txn.complete();
|
||||||
|
this._summary.applyChanges(data);
|
||||||
|
this._emitUpdate();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const lastEventId = await this._getLastEventId();
|
||||||
|
if (lastEventId) {
|
||||||
|
await this._hsApi.receipt(this._roomId, "m.read", lastEventId);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
// ignore ConnectionError
|
||||||
|
if (err.name !== "ConnectionError") {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user