mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-23 11:42:21 +00:00
Space Missions no longer runs as a Context mode. The launches layer owns its Satellites dependency, including the rule that a Satellites off asked for after Space Missions was switched on ends it (request order decides), and a small controller connects the layer to its own panel and store. Context no longer isolates, snapshots or restores Space Missions or Satellites, so Contacts and Space Missions run together in either order, and scene playback no longer exits an isolating mode. Settled by the owner: Contacts leaves Satellites as it is, and only a person's or voice Satellites off ends Space Missions; a scene, story, preset or other programmatic off does not. Turning the layer on by hand or by voice, choosing it at first run, or picking a mission on the globe opens the Space Missions panel, and on a phone its Missions sheet. Asking voice to open the panel while the layer is off is refused with a reason, and voice never opens it while the Cockpit owns the screen. With no Context mode on, a voice Context off switches Space Missions off. A failed Satellites restore no longer cuts the layer's teardown short. Mission labels on the globe select their mission. The layer names a failed first index load itself, so the Context toast no longer imports Space Missions code. Also carries the satellites request ordering and DataLayerManager.waitForLayerIdle, the share token for the panel, voice panel ids, Cockpit folding the panel away and the phone tab ellipsis. The panel shares the rail gutters and hover border of the other side panels. On top of the Omnibar: "open space missions panel" reaches the new panel, and Open Context no longer answers to "missions". Co-authored-by: Sameh Khamis <[email protected]>
160 lines
5.0 KiB
JavaScript
160 lines
5.0 KiB
JavaScript
import { _initGlobalContextPanel } from './contextBindings.js';
|
|
import {
|
|
_syncContextModeButtons,
|
|
_presentContext,
|
|
} from './contextPresentation.js';
|
|
import {
|
|
_trackContextLayerReaction,
|
|
_waitForContextLayerSettlement,
|
|
_captureContextSessionSnapshot,
|
|
_restoreContextSession,
|
|
_restoreContextSessionAfterLayerSettles,
|
|
} from './contextSession.js';
|
|
import {
|
|
_selectContextMode,
|
|
_deactivateContextForLayerChange,
|
|
_clearLayersOutsideContextMode,
|
|
} from './contextTransactions.js';
|
|
import { _handleContextLayerChange } from './contextLayerChanges.js';
|
|
import {
|
|
_runUserFacingContextAction,
|
|
_claimContextVisualAuthority,
|
|
getContextModeState,
|
|
setContextMode,
|
|
clearSelectedLayers,
|
|
} from './contextActions.js';
|
|
import { connectContextManager } from './contextSubscriptions.js';
|
|
|
|
/**
|
|
* Own Context transactions and controls through explicit layer and
|
|
* presentation ports. The mode switch is presented through `publish`
|
|
* (the app hands it the `gev-context` store) and rendered by the view.
|
|
*/
|
|
export class ContextControls {
|
|
constructor({ elements, installations, actions, publish = () => {} }) {
|
|
Object.assign(this, elements);
|
|
this.installations = installations;
|
|
this.actions = actions;
|
|
this.publish = publish;
|
|
this._installationsSearchBusy = false;
|
|
this.listeners = new AbortController();
|
|
this.destroyed = false;
|
|
this._dataManager = null;
|
|
this._contextMode = null;
|
|
this._contextModeChanging = false;
|
|
this._contextModeGeneration = 0;
|
|
this._contextModeEntering = null;
|
|
this._contextSessionSnapshot = null;
|
|
this._contextRestoreState = null;
|
|
this._contextLayerReactionPromises = new Set();
|
|
this._preservePanelStateDuringLayerClear = false;
|
|
/** Layers Context isolation is switching off right now. */
|
|
this._isolatingLayerIds = new Set();
|
|
this._userFacingContextNotificationTokens = new Set();
|
|
this._clearSelectedLayersPromise = null;
|
|
this._clearSelectedLayersManagerPromise = null;
|
|
this._initGlobalContextPanel();
|
|
}
|
|
showToast(...args) {
|
|
if (!this.destroyed) this.actions.showToast(...args);
|
|
}
|
|
/**
|
|
* Whether Context isolation is switching this layer off right now: it is
|
|
* suspended, and leaving the mode restores it. A switch-off by the user,
|
|
* inside the mode or out of it, is not.
|
|
* @param {string} layerId Layer id.
|
|
* @returns {boolean}
|
|
*/
|
|
suspendsLayer(layerId) {
|
|
return this._isolatingLayerIds.has(layerId);
|
|
}
|
|
setClearBusy(...args) {
|
|
if (!this.destroyed) this.actions.setClearBusy(...args);
|
|
}
|
|
get cockpitView() {
|
|
return this.actions.getCockpit();
|
|
}
|
|
listen(target, type, callback, options = {}) {
|
|
target?.addEventListener(type, callback, {
|
|
...options,
|
|
signal: this.listeners.signal,
|
|
});
|
|
}
|
|
connect(manager) {
|
|
return connectContextManager.call(this, manager);
|
|
}
|
|
disconnect() {
|
|
for (const field of [
|
|
'_contextManagerUnsubscribe',
|
|
'_dataManagerBeforeDestroyUnsubscribe',
|
|
'_dataManagerVisibilityGuardUnsubscribe',
|
|
'_dataManagerVisibilityRequestUnsubscribe',
|
|
]) {
|
|
this[field]?.();
|
|
this[field] = null;
|
|
}
|
|
}
|
|
stop() {
|
|
if (this.destroyed) return;
|
|
this.destroyed = true;
|
|
this._contextModeGeneration++;
|
|
this.listeners.abort();
|
|
}
|
|
async restoreForDisposal() {
|
|
this._contextModeChanging = true;
|
|
this._contextMode = null;
|
|
await this._restoreContextSession();
|
|
}
|
|
_initGlobalContextPanel(...args) {
|
|
return _initGlobalContextPanel.call(this, ...args);
|
|
}
|
|
_syncContextModeButtons(...args) {
|
|
return _syncContextModeButtons.call(this, ...args);
|
|
}
|
|
_presentContext(...args) {
|
|
return _presentContext.call(this, ...args);
|
|
}
|
|
_trackContextLayerReaction(...args) {
|
|
return _trackContextLayerReaction.call(this, ...args);
|
|
}
|
|
_waitForContextLayerSettlement(...args) {
|
|
return _waitForContextLayerSettlement.call(this, ...args);
|
|
}
|
|
_captureContextSessionSnapshot(...args) {
|
|
return _captureContextSessionSnapshot.call(this, ...args);
|
|
}
|
|
_restoreContextSession(...args) {
|
|
return _restoreContextSession.call(this, ...args);
|
|
}
|
|
_restoreContextSessionAfterLayerSettles(...args) {
|
|
return _restoreContextSessionAfterLayerSettles.call(this, ...args);
|
|
}
|
|
_selectContextMode(...args) {
|
|
return _selectContextMode.call(this, ...args);
|
|
}
|
|
_deactivateContextForLayerChange(...args) {
|
|
return _deactivateContextForLayerChange.call(this, ...args);
|
|
}
|
|
_clearLayersOutsideContextMode(...args) {
|
|
return _clearLayersOutsideContextMode.call(this, ...args);
|
|
}
|
|
_handleContextLayerChange(...args) {
|
|
return _handleContextLayerChange.call(this, ...args);
|
|
}
|
|
_runUserFacingContextAction(...args) {
|
|
return _runUserFacingContextAction.call(this, ...args);
|
|
}
|
|
_claimContextVisualAuthority(...args) {
|
|
return _claimContextVisualAuthority.call(this, ...args);
|
|
}
|
|
getContextModeState(...args) {
|
|
return getContextModeState.call(this, ...args);
|
|
}
|
|
setContextMode(...args) {
|
|
return setContextMode.call(this, ...args);
|
|
}
|
|
clearSelectedLayers(...args) {
|
|
return clearSelectedLayers.call(this, ...args);
|
|
}
|
|
}
|