mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Retain live flights and earthquake observations across globe switches
This commit is contained in:
1 parent
a0e5f04c30
commit
c0062c4d3d
17 files changed
+428
-66
No files matched your search
@@ -470,6 +470,36 @@ export class LayerStateCoordinator {
|
||||
return null;
|
||||
}
|
||||
|
||||
// On an in-page engine switch, an attached session model can already own
|
||||
// this exact contact. Ordinary shared links must still verify the source.
|
||||
retainedTrackingTarget() {
|
||||
const selected = this._selectedShareTrackingTarget();
|
||||
if (!selected || !this.dataManager.isEnabled(selected.layerId)) return null;
|
||||
const model = this.dataManager.layers.get(selected.layerId)?.module;
|
||||
if (
|
||||
model?.attachRenderer &&
|
||||
model.getParams?.()[selected.optionKey] === selected.targetId &&
|
||||
model.hasContact?.(selected.targetId) === true
|
||||
) return selected;
|
||||
return null;
|
||||
}
|
||||
|
||||
resumeRetainedTracking(previous) {
|
||||
const selected = this.retainedTrackingTarget();
|
||||
if (
|
||||
!selected || selected.layerId !== previous.layerId ||
|
||||
selected.targetId !== previous.targetId
|
||||
) return null;
|
||||
const model = this.dataManager.layers.get(selected.layerId).module;
|
||||
const followed = model.trackById(selected.targetId, {
|
||||
origin: LAYER_RESTORE_ORIGINS.share,
|
||||
});
|
||||
if (!followed) return null;
|
||||
const result = { ...selected, status: 'found', classification: 'followed', cleared: false };
|
||||
this._publishTrackingRestoreStatus(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
_passivelyClearTrackingSelection(selected) {
|
||||
const current =
|
||||
this._durableState.options?.[selected.optionOwner]?.[selected.optionKey];
|
||||
|
||||
@@ -121,6 +121,50 @@ export class LayerLifecycle {
|
||||
this._registerLayer(layerModule);
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the scene only. Models with an explicit renderer lifetime keep
|
||||
* their entry, polling interval, visibility intents and in-flight source.
|
||||
* Legacy modules use their ordinary teardown until they gain that contract.
|
||||
*/
|
||||
async detachScene() {
|
||||
for (const [id, entry] of [...this.layers]) {
|
||||
await entry.toggleChain.catch(() => {});
|
||||
if (entry.module.attachRenderer && entry.module.detachRenderer) {
|
||||
if (entry.initialized) entry.module.detachRenderer(this.viewer);
|
||||
} else if (!(await this.destroyLayer(id))) {
|
||||
throw new Error(`Cannot detach layer ${id}`);
|
||||
}
|
||||
}
|
||||
this.viewer = null;
|
||||
this.engine = null;
|
||||
this._registrationsFinalized = false;
|
||||
this._registrationDispositions = null;
|
||||
}
|
||||
|
||||
/** Bind the next catalog only after the preceding scene released its entries. */
|
||||
bindCatalog(viewer, engine, catalog) {
|
||||
if (this._registrationsFinalized) throw new Error('Scene already attached');
|
||||
this.viewer = viewer;
|
||||
this.engine = engine ?? engineFromViewer(viewer) ?? null;
|
||||
this._catalogSourceAvailability = catalog.getSourceAvailability;
|
||||
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());
|
||||
}
|
||||
}
|
||||
// Retained entries may appear anywhere in the directory. Preserve both
|
||||
// catalog order (panel/serialization) and each live entry's identity.
|
||||
for (const { id } of catalog.layers) {
|
||||
const entry = this.layers.get(id);
|
||||
this.layers.delete(id);
|
||||
this.layers.set(id, entry);
|
||||
}
|
||||
this.finalizeRegistrations(catalog.metadata);
|
||||
}
|
||||
|
||||
/** Register a synthetic layer after sealing in an explicitly dev-enabled manager. */
|
||||
registerForQa(layerModule) {
|
||||
if (!this._allowQaRegistration || !this._registrationsFinalized) {
|
||||
|
||||
Reference in new issue
Block a user