mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
centralize update emitting in room
This commit is contained in:
parent
bce46daa9c
commit
f3f07a0672
@ -231,8 +231,7 @@ export class Room extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (emitChange) {
|
if (emitChange) {
|
||||||
this.emit("change");
|
this._emitUpdate();
|
||||||
this._emitCollectionChange(this);
|
|
||||||
}
|
}
|
||||||
if (this._timeline) {
|
if (this._timeline) {
|
||||||
this._timeline.appendLiveEntries(newTimelineEntries);
|
this._timeline.appendLiveEntries(newTimelineEntries);
|
||||||
@ -442,6 +441,13 @@ export class Room extends EventEmitter {
|
|||||||
return !!this._timeline;
|
return !!this._timeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_emitUpdate() {
|
||||||
|
// once for event emitter listeners
|
||||||
|
this.emit("change");
|
||||||
|
// and once for collection listeners
|
||||||
|
this._emitCollectionChange(this);
|
||||||
|
}
|
||||||
|
|
||||||
async clearUnread() {
|
async clearUnread() {
|
||||||
if (this.isUnread || this.notificationCount) {
|
if (this.isUnread || this.notificationCount) {
|
||||||
const txn = await this._storage.readWriteTxn([
|
const txn = await this._storage.readWriteTxn([
|
||||||
@ -456,8 +462,7 @@ export class Room extends EventEmitter {
|
|||||||
}
|
}
|
||||||
await txn.complete();
|
await txn.complete();
|
||||||
this._summary.applyChanges(data);
|
this._summary.applyChanges(data);
|
||||||
this.emit("change");
|
this._emitUpdate();
|
||||||
this._emitCollectionChange(this);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const lastEventId = await this._getLastEventId();
|
const lastEventId = await this._getLastEventId();
|
||||||
|
Loading…
Reference in New Issue
Block a user