mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
feat(globe): answer both reset buttons through the globe actions store
The top-center and cockpit reset buttons call the location controls' new reset() through the globe actions store, and render a reset under way from it, instead of the location controls binding their clicks and the navigation writing their labels. The store keeps each owner's reset under way like its clear, and controls replaced mid-reset keep it on the buttons. LocationControls no longer takes resetButtons.
This commit is contained in:
1 parent
eccaeea0c4
commit
b4ee2321cf
17 files changed
+173
-84
No files matched your search
@@ -3,33 +3,43 @@ import { computed, ref, shallowReactive } from 'vue';
|
||||
import { createOwners } from './owners.js';
|
||||
|
||||
/**
|
||||
* The top-center globe actions as their view renders them. The shell
|
||||
* publishes whether a clear of the selected data layers is under way and the
|
||||
* camera's tilt and heading, and answers the buttons through act().
|
||||
* The top-center globe actions as their view renders them, and the cockpit's
|
||||
* reset. The shell publishes whether a clear of the selected data layers or a
|
||||
* reset to the full globe view is under way and the camera's tilt and
|
||||
* heading, and answers the buttons through act().
|
||||
*/
|
||||
export const useGlobeActionsStore = defineStore('gev-globe-actions', () => {
|
||||
const owners = createOwners();
|
||||
// Who answers which action, as the computed state below reads it.
|
||||
const ownership = ref(0);
|
||||
/** Each clear owner's clear under way, by its token. */
|
||||
const busyBy = shallowReactive(new Map());
|
||||
|
||||
/**
|
||||
* Whether the clear owner's clear is under way; null until it says. Each
|
||||
* owner keeps its own, so the button shows the one that answers it.
|
||||
* Whether the work behind an action is under way, kept per owner so its
|
||||
* button shows the owner that answers it; null until that owner says.
|
||||
*/
|
||||
const clearBusy = computed(() => {
|
||||
void ownership.value;
|
||||
return busyBy.get(owners.ownerOf('clear')) ?? null;
|
||||
});
|
||||
|
||||
/**
|
||||
* @param {object} token The clear owner's, from connect().
|
||||
* @param {boolean} busy
|
||||
*/
|
||||
function publishClearBusy(token, busy) {
|
||||
busyBy.set(token, Boolean(busy));
|
||||
function ownedBusy(name) {
|
||||
const byOwner = shallowReactive(new Map());
|
||||
const busy = computed(() => {
|
||||
void ownership.value;
|
||||
return byOwner.get(owners.ownerOf(name)) ?? null;
|
||||
});
|
||||
/**
|
||||
* @param {object} token The owner's, from connect().
|
||||
* @param {boolean} value
|
||||
*/
|
||||
const publish = (token, value) => {
|
||||
byOwner.set(token, Boolean(value));
|
||||
};
|
||||
return { byOwner, busy, publish };
|
||||
}
|
||||
const clearing = ownedBusy('clear');
|
||||
const resetting = ownedBusy('reset');
|
||||
/** Whether a clear of the selected data layers is under way. */
|
||||
const clearBusy = clearing.busy;
|
||||
const publishClearBusy = clearing.publish;
|
||||
/** Whether a reset to the full globe view is under way. */
|
||||
const resetBusy = resetting.busy;
|
||||
const publishResetting = resetting.publish;
|
||||
|
||||
/**
|
||||
* Whether the map reads as tilted and the camera's whole-degree heading;
|
||||
@@ -63,7 +73,8 @@ export const useGlobeActionsStore = defineStore('gev-globe-actions', () => {
|
||||
|
||||
function detach(token) {
|
||||
owners.detach(token);
|
||||
busyBy.delete(token);
|
||||
clearing.byOwner.delete(token);
|
||||
resetting.byOwner.delete(token);
|
||||
ownership.value += 1;
|
||||
}
|
||||
|
||||
@@ -72,6 +83,8 @@ export const useGlobeActionsStore = defineStore('gev-globe-actions', () => {
|
||||
return {
|
||||
clearBusy,
|
||||
publishClearBusy,
|
||||
resetBusy,
|
||||
publishResetting,
|
||||
camera,
|
||||
publishCamera,
|
||||
connect,
|
||||
|
||||
Reference in new issue
Block a user