Brainstorm code

Signed-off-by: RMidhunSuresh <hi@midhun.dev>
This commit is contained in:
RMidhunSuresh 2021-10-26 12:12:58 +05:30
parent c92d6ecbb6
commit b648b87687
2 changed files with 33 additions and 2 deletions

View file

@ -49,6 +49,30 @@ export class TimelineViewModel extends ViewModel {
this._showJumpDown = false;
}
async watchForGapFill(gapPromise, tileRange, gapTile) {
console.log("watchForGapFill called");
let hasSeenUpdate = false;
const func = (idx, tile) => {
if (tile.shape !== "gap") {
hasSeenUpdate = true;
}
}
const subscription = {
onAdd: (idx, tile) => func(idx, tile),
onUpdate: (idx, tile) => func(idx, tile),
onRemove: (idx, tile) => func(idx, tile)
};
this.tiles.subscribe(subscription);
await gapPromise;
this.tiles.unsubscribe(subscription);
console.log("hasSeenUpdate is ", hasSeenUpdate);
if (!hasSeenUpdate) {
// this.watchForGapFill(gapTile.notifyVisible(), undefined, gapTile);
const { startTile, endTile } = tileRange;
this.setVisibleTileRange(startTile, endTile);
}
}
/** if this.tiles is empty, call this with undefined for both startTile and endTile */
setVisibleTileRange(startTile, endTile) {
// don't clear these once done as they are used to check
@ -73,7 +97,11 @@ export class TimelineViewModel extends ViewModel {
const startIndex = this._tiles.getTileIndex(this._startTile);
const endIndex = this._tiles.getTileIndex(this._endTile);
for (const tile of this._tiles.sliceIterator(startIndex, endIndex + 1)) {
tile.notifyVisible();
const ret = tile.notifyVisible();
if (ret && !tile.isAtTop) {
console.log("ret is", ret);
this.watchForGapFill(ret, { startTile, endTile }, tile);
}
}
loadTop = startIndex < 10;
this._setShowJumpDown(endIndex < (this._tiles.length - 1));

View file

@ -43,10 +43,13 @@ export class GapTile extends SimpleTile {
this.emitChange("isLoading");
}
}
else {
console.log("Not entering fill() logic");
}
}
notifyVisible() {
this.fill();
return this.fill();
}
get isAtTop() {