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); this.emitRemove(tileIdx, tile);
prevTile?.updateNextSibling(nextTile); prevTile?.updateNextSibling(nextTile);
nextTile?.updatePreviousSibling(prevTile); 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 // 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 // let item know it has a new sibling
updateNextSibling(next: ITile<BaseEntry> | undefined): UpdateAction { updateNextSibling(next: ITile<BaseEntry> | undefined): UpdateAction {
// TODO: next can be undefined when a pending event is removed if(!next) {
// TODO: we need a way to remove this date header // If we are the DateTile for the last tile in the timeline,
this._firstTileInDay = next!; // 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; const prevDateString = this._dateString;
this._dateString = undefined; this._dateString = undefined;
if (prevDateString && prevDateString !== this.date) { if (prevDateString && prevDateString !== this.date) {