mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 02:02:21 +00:00
Follow-ups to the photo viewer's move to a Vue view (#1868): - A panorama's open waits for a draw of the canvas counted from before it is shown, so a view that draws at once inside its listener no longer leaves the open pending; and when the last view unsubscribes, an open waiting on a draw goes on instead of hanging. - photoViewers.js supersedes the mounts not drawn on a microtask, after the winning presentation has reached every subscriber: a second subscriber sees the earlier mount, then the later one, never null between. - A presentation without a mountKey counts as the latest mount (among several without, the one that began presenting last), and one without actions or supersede is passed over without throwing. Both fields are documented on ViewerAdapter.subscribeView in registry.js and in the store's comment. - The guard test also refuses .width, .height, .ariaLabel, .id and .value writes in photoViewer.js, and .src writes outside loadImage, where only the off-page Image it creates may take one. - The test fakes draw every viewer through one shared view behind photoViewers.js's picker, as the application does, so provider and layer tests see supersede. Nothing changes in the running app. Co-authored-by: Manjunath Paparaju <[email protected]>
30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
import { defineStore } from 'pinia';
|
|
import { markRaw, shallowRef } from 'vue';
|
|
|
|
/**
|
|
* The Street Level photo viewer (KartaView, Panoramax) as its view renders
|
|
* it. The street-level layer presents it through `subscribePhotoViewer()`
|
|
* and the application shell publishes each presentation here.
|
|
*/
|
|
export const useStreetLevelPhotoStore = defineStore(
|
|
'gev-street-level-photo',
|
|
() => {
|
|
/**
|
|
* `{host, mountKey, providerId, label, alt, kind, src, fit, canvasKey,
|
|
* dragging, prevLabel, prevDisabled, nextLabel, nextDisabled, actions}`,
|
|
* or null while no photo viewer is mounted. Of the viewers mounting in
|
|
* the host, only the one mounted last (the largest `mountKey`) is
|
|
* published; `actions.supersede()` tells the others they are not drawn
|
|
* (see `ViewerAdapter.subscribeView` in src/layers/streetLevel/registry.js).
|
|
*/
|
|
const photo = shallowRef(null);
|
|
|
|
/** @param {?object} next A fresh presentation; every publish re-renders. */
|
|
function publish(next) {
|
|
photo.value = next && markRaw(next);
|
|
}
|
|
|
|
return { photo, publish };
|
|
},
|
|
);
|