forked from mystiq/hydrogen-web
clear unread state 2s after opening the room
This commit is contained in:
parent
89392434ad
commit
dbf5e59d87
1 changed files with 14 additions and 0 deletions
|
@ -32,6 +32,7 @@ export class RoomViewModel extends ViewModel {
|
|||
this._sendError = null;
|
||||
this._closeCallback = closeCallback;
|
||||
this._composerVM = new ComposerViewModel(this);
|
||||
this._clearUnreadTimout = null;
|
||||
}
|
||||
|
||||
async load() {
|
||||
|
@ -49,6 +50,15 @@ export class RoomViewModel extends ViewModel {
|
|||
this._timelineError = err;
|
||||
this.emitChange("error");
|
||||
}
|
||||
this._clearUnreadTimout = this.clock.createTimeout(2000);
|
||||
try {
|
||||
await this._clearUnreadTimout.elapsed();
|
||||
await this._room.clearUnread();
|
||||
} catch (err) {
|
||||
if (err.name !== "AbortError") {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
@ -57,6 +67,10 @@ export class RoomViewModel extends ViewModel {
|
|||
// will stop the timeline from delivering updates on entries
|
||||
this._timeline.close();
|
||||
}
|
||||
if (this._clearUnreadTimout) {
|
||||
this._clearUnreadTimout.abort();
|
||||
this._clearUnreadTimout = null;
|
||||
}
|
||||
}
|
||||
|
||||
close() {
|
||||
|
|
Loading…
Reference in a new issue