forked from mystiq/hydrogen-web
don't fail to clear unread state when offline
also update UI before network request
This commit is contained in:
parent
2bfbb41ee7
commit
0d8ff34c55
1 changed files with 12 additions and 4 deletions
|
@ -214,10 +214,6 @@ export class Room extends EventEmitter {
|
|||
|
||||
async clearUnread() {
|
||||
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([
|
||||
this._storage.storeNames.roomSummary,
|
||||
]);
|
||||
|
@ -232,6 +228,18 @@ export class Room extends EventEmitter {
|
|||
this._summary.applyChanges(data);
|
||||
this.emit("change");
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue