diff --git a/src/platform/web/ui/general/ListView.ts b/src/platform/web/ui/general/ListView.ts index c3ac49a4..e6d15755 100644 --- a/src/platform/web/ui/general/ListView.ts +++ b/src/platform/web/ui/general/ListView.ts @@ -27,7 +27,7 @@ interface IOptions { parentProvidesUpdates?: boolean } -type SubscriptionHandle = () => undefined; +type SubscriptionHandle = () => void; export class ListView implements IView { @@ -115,7 +115,8 @@ export class ListView implements IView { } private _unloadList() { - this._subscription = this._subscription!(); + this._subscription!() + this._subscription = undefined; for (let child of this._childInstances!) { child.unmount(); } @@ -137,26 +138,34 @@ export class ListView implements IView { this._root!.appendChild(fragment); } - protected onAdd(idx: number, value: T) { + onReset() { + for (const child of this._childInstances!) { + child.root()!.remove(); + child.unmount(); + } + this._childInstances!.length = 0; + } + + onAdd(idx: number, value: T) { const child = this._childCreator(value); this._childInstances!.splice(idx, 0, child); insertAt(this._root!, idx, mountView(child, this._mountArgs)); } - protected onRemove(idx: number, value: T) { + onRemove(idx: number, value: T) { const [child] = this._childInstances!.splice(idx, 1); child.root()!.remove(); child.unmount(); } - protected onMove(fromIdx: number, toIdx: number, value: T) { + onMove(fromIdx: number, toIdx: number, value: T) { const [child] = this._childInstances!.splice(fromIdx, 1); this._childInstances!.splice(toIdx, 0, child); child.root()!.remove(); insertAt(this._root!, toIdx, child.root()! as Element); } - protected onUpdate(i: number, value: T, params: any) { + onUpdate(i: number, value: T, params: any) { if (this._childInstances) { const instance = this._childInstances![i]; instance && instance.update(value, params); diff --git a/src/platform/web/ui/session/room/TimelineView.ts b/src/platform/web/ui/session/room/TimelineView.ts index 23cf0aac..da3dc537 100644 --- a/src/platform/web/ui/session/room/TimelineView.ts +++ b/src/platform/web/ui/session/room/TimelineView.ts @@ -211,7 +211,12 @@ class TilesListView extends ListView { this.onChanged = onChanged; } - protected onUpdate(index: number, value: SimpleTile, param: any) { + onReset() { + super.onReset(); + this.onChanged(); + } + + onUpdate(index: number, value: SimpleTile, param: any) { if (param === "shape") { const ExpectedClass = viewClassForEntry(value); const child = this.getChildInstanceByIndex(index); @@ -227,17 +232,17 @@ class TilesListView extends ListView { this.onChanged(); } - protected onAdd(idx: number, value: SimpleTile) { + onAdd(idx: number, value: SimpleTile) { super.onAdd(idx, value); this.onChanged(); } - protected onRemove(idx: number, value: SimpleTile) { + onRemove(idx: number, value: SimpleTile) { super.onRemove(idx, value); this.onChanged(); } - protected onMove(fromIdx: number, toIdx: number, value: SimpleTile) { + onMove(fromIdx: number, toIdx: number, value: SimpleTile) { super.onMove(fromIdx, toIdx, value); this.onChanged(); }