mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
support clearing unread when focusing a room
This commit is contained in:
parent
614ec08238
commit
dc1357bb31
@ -51,10 +51,18 @@ export class RoomViewModel extends ViewModel {
|
|||||||
this._timelineError = err;
|
this._timelineError = err;
|
||||||
this.emitChange("error");
|
this.emitChange("error");
|
||||||
}
|
}
|
||||||
|
this._clearUnreadAfterDelay();
|
||||||
|
}
|
||||||
|
|
||||||
|
async _clearUnreadAfterDelay() {
|
||||||
|
if (this._clearUnreadTimout) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this._clearUnreadTimout = this.clock.createTimeout(2000);
|
this._clearUnreadTimout = this.clock.createTimeout(2000);
|
||||||
try {
|
try {
|
||||||
await this._clearUnreadTimout.elapsed();
|
await this._clearUnreadTimout.elapsed();
|
||||||
await this._room.clearUnread();
|
await this._room.clearUnread();
|
||||||
|
this._clearUnreadTimout = null;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.name !== "AbortError") {
|
if (err.name !== "AbortError") {
|
||||||
throw err;
|
throw err;
|
||||||
@ -62,6 +70,10 @@ export class RoomViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
focus() {
|
||||||
|
this._clearUnreadAfterDelay();
|
||||||
|
}
|
||||||
|
|
||||||
dispose() {
|
dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
if (this._clearUnreadTimout) {
|
if (this._clearUnreadTimout) {
|
||||||
|
Loading…
Reference in New Issue
Block a user