mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
don't fail to clear unread state when offline
also update UI before network request
This commit is contained in:
parent
2bfbb41ee7
commit
0d8ff34c55
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user