don't fail to clear unread state when offline

also update UI before network request
This commit is contained in:
Bruno Windels 2020-08-21 15:23:25 +02:00
parent 2bfbb41ee7
commit 0d8ff34c55

View File

@ -214,10 +214,6 @@ export class Room extends EventEmitter {
async clearUnread() { async clearUnread() {
if (this.isUnread || this.notificationCount) { if (this.isUnread || this.notificationCount) {
const lastEventId = await this._getLastEventId();
if (lastEventId) {
await this._hsApi.receipt(this._roomId, "m.read", lastEventId);
}
const txn = await this._storage.readWriteTxn([ const txn = await this._storage.readWriteTxn([
this._storage.storeNames.roomSummary, this._storage.storeNames.roomSummary,
]); ]);
@ -232,6 +228,18 @@ export class Room extends EventEmitter {
this._summary.applyChanges(data); this._summary.applyChanges(data);
this.emit("change"); this.emit("change");
this._emitCollectionChange(this); this._emitCollectionChange(this);
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;
}
}
} }
} }