remove date headers when removing pending tiles

This commit is contained in:
Bruno Windels 2022-11-25 12:09:28 +01:00
parent cb0ab589de
commit 7c6d651b32
2 changed files with 12 additions and 3 deletions

View File

@ -255,6 +255,10 @@ export class TilesCollection extends BaseObservableList {
this.emitRemove(tileIdx, tile);
prevTile?.updateNextSibling(nextTile);
nextTile?.updatePreviousSibling(prevTile);
if (prevTile && prevTile.shape === TileShape.DateHeader && (!nextTile || !nextTile.needsDateSeparator)) {
this._removeTile(tileIdx - 1, prevTile);
}
}
// would also be called when unloading a part of the timeline

View File

@ -127,9 +127,14 @@ export class DateTile extends ViewModel implements ITile<BaseEventEntry> {
// let item know it has a new sibling
updateNextSibling(next: ITile<BaseEntry> | undefined): UpdateAction {
// TODO: next can be undefined when a pending event is removed
// TODO: we need a way to remove this date header
this._firstTileInDay = next!;
if(!next) {
// If we are the DateTile for the last tile in the timeline,
// and that tile gets removed, next would be undefined
// and this DateTile would be removed as well,
// so do nothing
return;
}
this._firstTileInDay = next;
const prevDateString = this._dateString;
this._dateString = undefined;
if (prevDateString && prevDateString !== this.date) {