mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Keep Contacts, active layer intents and mapped sites across globe switches
This commit is contained in:
1 parent
81bcae907f
commit
87bbe14748
35 files changed
+465
-118
No files matched your search
@@ -102,6 +102,7 @@ export class LayerStateCoordinator {
|
||||
start({
|
||||
shareLayerState = null,
|
||||
allowLocalState = true,
|
||||
handoffLayers = null,
|
||||
shareCreatedAtMs = null,
|
||||
} = {}) {
|
||||
if (this._destroyed)
|
||||
@@ -139,11 +140,12 @@ export class LayerStateCoordinator {
|
||||
);
|
||||
this.shareLinkManager?.onLayerStateChange?.();
|
||||
this._notifyDurableState();
|
||||
if (!selected) return this.restorePromise;
|
||||
if (!selected && !handoffLayers) return this.restorePromise;
|
||||
this.restorePromise = this._restoreSelectedState(
|
||||
this._source === 'share'
|
||||
? LAYER_RESTORE_ORIGINS.share
|
||||
: LAYER_RESTORE_ORIGINS.local,
|
||||
handoffLayers,
|
||||
);
|
||||
return this.restorePromise;
|
||||
}
|
||||
@@ -365,7 +367,7 @@ export class LayerStateCoordinator {
|
||||
: this.restoreGate);
|
||||
}
|
||||
|
||||
async _restoreSelectedState(origin) {
|
||||
async _restoreSelectedState(origin, handoffLayers = null) {
|
||||
// One controller set per run: a superseded run must not clear the newer
|
||||
// run's controllers when it settles.
|
||||
const controllers = new Map();
|
||||
@@ -379,7 +381,18 @@ export class LayerStateCoordinator {
|
||||
const settled = await Promise.allSettled(
|
||||
LAYER_STATE_REGISTRY.map(async (entry) => {
|
||||
const controller = controllers.get(entry.id);
|
||||
const targetEnabled = enabled.has(entry.id);
|
||||
const live = handoffLayers?.get(entry.id);
|
||||
const targetEnabled = live?.enabled ?? enabled.has(entry.id);
|
||||
// A same-document engine choice retains operational layer intents.
|
||||
// The share still owns durable preferences and later history visits.
|
||||
if (live && this.dataManager.layers.get(entry.id) === live.entry &&
|
||||
!live.entry.lifecycleUncertain && live.entry.enabled === targetEnabled) {
|
||||
return {
|
||||
layerId: entry.id, targetEnabled, origin, phase: 'retained',
|
||||
...currentLayerOutcome(this.dataManager, entry.id),
|
||||
appliedOptions: {}, persistenceWrite: false, succeeded: true,
|
||||
};
|
||||
}
|
||||
const options = layerOptionsForRestore(this._durableState, entry.id);
|
||||
if (origin === LAYER_RESTORE_ORIGINS.share && options) {
|
||||
for (const trackingKey of Object.values(
|
||||
|
||||
@@ -147,12 +147,16 @@ export class LayerLifecycle {
|
||||
this.viewer = viewer;
|
||||
this.engine = engine ?? engineFromViewer(viewer) ?? null;
|
||||
this._catalogSourceAvailability = catalog.getSourceAvailability;
|
||||
const attachments = [];
|
||||
for (const layer of catalog.layers) {
|
||||
const entry = this.layers.get(layer.id);
|
||||
if (!entry) this.register(layer);
|
||||
else {
|
||||
if (entry.module !== layer) throw new Error(`Layer owner changed: ${layer.id}`);
|
||||
if (entry.initialized) layer.attachRenderer(viewer, this._moduleContext());
|
||||
if (entry.initialized) {
|
||||
const ready = layer.attachRenderer(viewer, this._moduleContext());
|
||||
if (ready?.then) attachments.push(ready);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Retained entries may appear anywhere in the directory. Preserve both
|
||||
@@ -163,6 +167,7 @@ export class LayerLifecycle {
|
||||
this.layers.set(id, entry);
|
||||
}
|
||||
this.finalizeRegistrations(catalog.metadata);
|
||||
if (attachments.length) return Promise.all(attachments);
|
||||
}
|
||||
|
||||
/** Register a synthetic layer after sealing in an explicitly dev-enabled manager. */
|
||||
|
||||
@@ -1984,18 +1984,6 @@ test('cockpit blocks only non-aircraft Context camera flights', () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('vessel entry and selection framing both use the 3 km focus radius', () => {
|
||||
assert.match(
|
||||
militaryAwarenessSource,
|
||||
/const\s*VESSEL_FOCUS_RADIUS_M\s*=\s*3000;/,
|
||||
);
|
||||
const focusRadiusUses =
|
||||
militaryAwarenessSource.match(
|
||||
/new\s*Cesium\.BoundingSphere\(\s*vessel\.position,\s*VESSEL_FOCUS_RADIUS_M,?\s*\)/g,
|
||||
) || [];
|
||||
assert.equal(focusRadiusUses.length, 2);
|
||||
});
|
||||
|
||||
test('awareness rescans only for invalidation, source change, or meaningful movement', () => {
|
||||
assert.equal(
|
||||
awarenessRefreshRequired({
|
||||
@@ -3081,6 +3069,7 @@ test('every Context camera flight without a tracked entity takes navigation auth
|
||||
assert.deepEqual(taken, ['context-vessel-focus']);
|
||||
// The announcement precedes the flight, never trails it.
|
||||
assert.equal(runtime.cameraFlights.length, 1);
|
||||
assert.equal(runtime.cameraFlights[0].sphere.radius, 3000);
|
||||
|
||||
militaryAwarenessLayer.focusTarget('military-installations', 'inst-1');
|
||||
assert.deepEqual(taken, [
|
||||
@@ -3119,6 +3108,7 @@ test('Contacts vessel autofocus takes navigation authority before it frames', as
|
||||
// Activation enables dependencies before it auto-focuses.
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
assert.equal(runtime.cameraFlights.length, 1, 'autofocus framed a vessel');
|
||||
assert.equal(runtime.cameraFlights[0].sphere.radius, 3000);
|
||||
assert.deepEqual(taken, [
|
||||
{
|
||||
reason: 'context-vessel-autofocus',
|
||||
|
||||
Reference in new issue
Block a user