mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Stub setBase: imagery is added before photoreal is awaited
An unawaited setBase with photoreal and imagery, followed by another, added its imagery after the later call had set its own, leaving both. The imagery now goes in before anything is awaited, as the Cesium port adds it, and an overtaken call resolves settled: false.
This commit is contained in:
1 parent
ca82e23d94
commit
db80c9f141
2 files changed
+23
-2
No files matched your search
@@ -1590,10 +1590,17 @@ export function createStubRenderer(options = {}) {
|
|||||||
if (!current()) return superseded();
|
if (!current()) return superseded();
|
||||||
}
|
}
|
||||||
for (const layer of imageryLayers.slice()) layer.remove();
|
for (const layer of imageryLayers.slice()) layer.remove();
|
||||||
|
// The imagery is added before anything is awaited, so a later call,
|
||||||
|
// which removes it, always finds it.
|
||||||
|
const layers = (base.imagery ?? []).map((spec) => addImagery(spec));
|
||||||
if (base.photoreal !== undefined)
|
if (base.photoreal !== undefined)
|
||||||
await globe.setPhotoreal(base.photoreal);
|
await globe.setPhotoreal(base.photoreal);
|
||||||
const layers = (base.imagery ?? []).map((spec) => addImagery(spec));
|
// A base a later call replaced has not settled.
|
||||||
return { photoreal: photorealStatus, imagery: layers, settled: true };
|
return {
|
||||||
|
photoreal: photorealStatus,
|
||||||
|
imagery: layers,
|
||||||
|
settled: current(),
|
||||||
|
};
|
||||||
},
|
},
|
||||||
async setPhotoreal(spec) {
|
async setPhotoreal(spec) {
|
||||||
log('globe', 'setPhotoreal', [spec]);
|
log('globe', 'setPhotoreal', [spec]);
|
||||||
|
|||||||
@@ -238,3 +238,17 @@ test('a slow vector setBase a later setBase supersedes changes nothing, nor one
|
|||||||
globalThis.fetch = original;
|
globalThis.fetch = original;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('two setBase calls, neither awaited, leave the later one’s imagery alone', async () => {
|
||||||
|
const r = createStubRenderer();
|
||||||
|
const url = (name) => `https://${name}.invalid/{z}/{x}/{y}.png`;
|
||||||
|
const first = r.globe.setBase({
|
||||||
|
photoreal: null,
|
||||||
|
imagery: [{ kind: 'xyz', url: url('a') }],
|
||||||
|
});
|
||||||
|
const second = r.globe.setBase({ imagery: [{ kind: 'xyz', url: url('b') }] });
|
||||||
|
const [, later] = await Promise.all([first, second]);
|
||||||
|
assert.deepEqual(r.globe.imagery.list(), later.imagery);
|
||||||
|
assert.equal((await first).settled, false, 'the overtaken one');
|
||||||
|
r.destroy();
|
||||||
|
});
|
||||||
Reference in new issue
Block a user