Street Level photo viewer: take a moved-off canvas back, and close a mount unmounted in its first draw

A canvas the panorama moved off (a second view drew its own) is no longer
ignored for good: its draws are counted, so an open waiting on one goes on,
and once a single view is left its canvas is taken back. Before, after the
second view left, the next 360° open waited forever and the panorama stayed
on the departed view's canvas.

A mount whose view unmounts it inside its first draw now fails as closed,
as every other unmounted mount does, rather than with a TypeError.

Both found in review; each new test fails without its fix.

Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
Sameh KhamisandManjunath Paparaju committed 2026-11-19 16:31:34 -08:00
1 parent 22485dcb01
commit 8c40eb957b
2 files changed
+68 -9

No files matched your search

@@ -954,3 +954,45 @@ test('two views handing back canvases of their own do not take the panorama in t
viewer.unmount();
for (const unsubscribe of unsubscribes) unsubscribe();
});
test('the panorama goes back to the one view left once a second view leaves', async () => {
const { viewer, renderers } = trackedViewer({
onReopen: (id) => viewer.open(id).catch(() => {}),
});
const one = elements();
const two = elements();
const unsubscribeOne = viewer.subscribeView(
(view) => view && attachAll(view, one),
);
await viewer.mount({});
await viewer.open('a');
// A second view subscribes and draws its own canvas: the panorama moves.
const unsubscribeTwo = viewer.subscribeView(
(view) => view && attachAll(view, two),
);
for (let i = 0; i < 5; i++) await tick();
assert.equal(renderers.at(-1).canvas, two.canvas);
unsubscribeTwo();
assert.ok(
await settles(viewer.open('b')),
'the next open is not left waiting',
);
for (let i = 0; i < 5; i++) await tick();
assert.equal(
renderers.at(-1).canvas,
one.canvas,
'the panorama is back on the view left',
);
assert.equal(renderers.at(-1).images.at(-1), 'b-first');
viewer.unmount();
unsubscribeOne();
});
test('a mount its view unmounts inside the first draw fails as closed', async () => {
const { viewer } = trackedViewer();
const unsubscribe = viewer.subscribeView((view) => {
if (view) viewer.unmount();
});
await assert.rejects(viewer.mount({}), /Street-level viewer was closed/);
unsubscribe();
});