mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2025-01-11 12:37:22 +01:00
Use flags to work around race
This commit is contained in:
parent
e94a9b36b3
commit
d0b34ef2ca
@ -47,9 +47,11 @@ export class TimelineViewModel extends ViewModel {
|
|||||||
this._requestedEndTile = null;
|
this._requestedEndTile = null;
|
||||||
this._requestScheduled = false;
|
this._requestScheduled = false;
|
||||||
this._showJumpDown = false;
|
this._showJumpDown = false;
|
||||||
|
this._watchMap = new WeakMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
async watchForGapFill(gapPromise, gapTile, depth = 0) {
|
async watchForGapFill(gapPromise, gapTile, depth = 0) {
|
||||||
|
this._watchMap.set(gapTile, true);
|
||||||
if (depth >= 10) {
|
if (depth >= 10) {
|
||||||
console.error("watchForGapFill exceeded a recursive depth of 10");
|
console.error("watchForGapFill exceeded a recursive depth of 10");
|
||||||
return;
|
return;
|
||||||
@ -69,8 +71,8 @@ export class TimelineViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
const subscription = {
|
const subscription = {
|
||||||
onAdd: (idx, tile) => checkForUpdate(idx, tile),
|
onAdd: (idx, tile) => checkForUpdate(idx, tile),
|
||||||
onUpdate: () => {/*checkForUpdate(idx, tile)*/},
|
|
||||||
onRemove: (idx, tile) => checkForUpdate(idx, tile),
|
onRemove: (idx, tile) => checkForUpdate(idx, tile),
|
||||||
|
onUpdate: () => { /* shouldn't be called */ },
|
||||||
onMove: () => { /* shouldn't be called */ },
|
onMove: () => { /* shouldn't be called */ },
|
||||||
onReset: () => { /* shouldn't be called */ }
|
onReset: () => { /* shouldn't be called */ }
|
||||||
};
|
};
|
||||||
@ -87,9 +89,10 @@ export class TimelineViewModel extends ViewModel {
|
|||||||
If gapResult resolves to false, then the gap is already being filled
|
If gapResult resolves to false, then the gap is already being filled
|
||||||
and is thus being tracked for updates by a previous invocation of this method
|
and is thus being tracked for updates by a previous invocation of this method
|
||||||
*/
|
*/
|
||||||
|
this._watchMap.set(gapTile, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!hasSeenUpdate) {
|
if (!hasSeenUpdate || !this._watchMap.get(gapTile)) {
|
||||||
this.watchForGapFill(gapTile.notifyVisible(), gapTile, depth + 1);
|
this.watchForGapFill(gapTile.notifyVisible(), gapTile, depth + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user