mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2025-02-02 07:31:38 +01:00
emit update from datetile when date might have changed
This commit is contained in:
parent
4abf18a5f1
commit
31f53d27c1
@ -151,7 +151,6 @@ export class TilesCollection extends BaseObservableList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_evaluateDateHeaderAtIdx(tileIdx) {
|
_evaluateDateHeaderAtIdx(tileIdx) {
|
||||||
//console.log("_evaluateDateHeaderAtIdx", tileIdx);
|
|
||||||
// consider two tiles after the inserted tile, because
|
// consider two tiles after the inserted tile, because
|
||||||
// the first of the two tiles may be a DateTile in which case,
|
// the first of the two tiles may be a DateTile in which case,
|
||||||
// we remove it after looking at the needsDateSeparator prop of the
|
// we remove it after looking at the needsDateSeparator prop of the
|
||||||
@ -167,25 +166,16 @@ export class TilesCollection extends BaseObservableList {
|
|||||||
const tile = this._tiles[idx];
|
const tile = this._tiles[idx];
|
||||||
const prevTile = idx > 0 ? this._tiles[idx - 1] : undefined;
|
const prevTile = idx > 0 ? this._tiles[idx - 1] : undefined;
|
||||||
const hasDateSeparator = prevTile?.shape === TileShape.DateHeader;
|
const hasDateSeparator = prevTile?.shape === TileShape.DateHeader;
|
||||||
if (tile.needsDateSeparator) {
|
if (tile.needsDateSeparator && !hasDateSeparator) {
|
||||||
if (hasDateSeparator) {
|
|
||||||
// TODO: replace this by return UpdateAction from updateNextSibling
|
|
||||||
// and do this in onAdd
|
|
||||||
//console.log(" update", idx - 1, prevTile?.shape, prevTile?.eventId);
|
|
||||||
this.emitUpdate(idx - 1, prevTile, "date");
|
|
||||||
} else {
|
|
||||||
//console.log(" add", idx, tile.shape, tile.eventId);
|
|
||||||
// adding a tile shift all the indices we need to consider
|
// adding a tile shift all the indices we need to consider
|
||||||
// especially given we consider removals for the tile that
|
// especially given we consider removals for the tile that
|
||||||
// comes after a datetile
|
// comes after a datetile
|
||||||
tileIdx += 1;
|
tileIdx += 1;
|
||||||
this._addTileAt(idx, tile.createDateSeparator());
|
this._addTileAt(idx, tile.createDateSeparator());
|
||||||
}
|
} else if (!tile.needsDateSeparator && hasDateSeparator) {
|
||||||
} else if (hasDateSeparator) {
|
|
||||||
// this is never triggered because needsDateSeparator is not cleared
|
// this is never triggered because needsDateSeparator is not cleared
|
||||||
// when loading more items because we don't do anything once the
|
// when loading more items because we don't do anything once the
|
||||||
// direct sibling is a DateTile
|
// direct sibling is a DateTile
|
||||||
//console.log(" remove", idx -1, prevTile?.shape, prevTile?.eventId);
|
|
||||||
this._removeTile(idx - 1, prevTile);
|
this._removeTile(idx - 1, prevTile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,8 +130,11 @@ export class DateTile extends ViewModel implements ITile<BaseEventEntry> {
|
|||||||
// TODO: next can be undefined when a pending event is removed
|
// TODO: next can be undefined when a pending event is removed
|
||||||
// TODO: we need a way to remove this date header
|
// TODO: we need a way to remove this date header
|
||||||
this._firstTileInDay = next!;
|
this._firstTileInDay = next!;
|
||||||
|
const prevDateString = this._dateString;
|
||||||
this._dateString = undefined;
|
this._dateString = undefined;
|
||||||
// TODO: do we need to reevaluate our date here and emit an update?
|
if (prevDateString && prevDateString !== this.date) {
|
||||||
|
this._emitUpdate?.(this, "date");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyVisible(): void {
|
notifyVisible(): void {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user