refactor: separate Layers panel presentation from lifecycle actions

This commit is contained in:
Sameh Khamis committed 2026-09-12 22:36:04 -07:00
1 parent 31f1923633
commit 07cf1695ff
14 files changed
+665 -398

No files matched your search

+8 -13
View File
@@ -1,3 +1,4 @@
import { bindClearLayersControl } from './ui/layers.js';
import { createMapSourceControls } from './ui/mapSource.js';
import { VisualEffects, STYLES, GLOBAL_POST_DEFAULTS, STYLE_PRESET_DEFAULTS, MILITARY_DETECTION_PRESET } from './ui/effects.js';
import { bindDisplayControls } from './ui/displayControls.js';
@@ -2087,7 +2088,6 @@ export class StyleManager {
this._globeResetHandler = null;
this._clearSelectedLayersPromise = null;
this._clearSelectedLayersManagerPromise = null;
this._clearSelectedLayersHandler = null;
this._dataManager = null;
this._cctvUnsubscribe = null;
this._radioUnsubscribe = null;
@@ -3331,6 +3331,7 @@ export class StyleManager {
_initMapStackControl() {
if (!this.mapStackController) return;
this._mapSourceControls?.destroy();
this._clearLayersControl?.destroy();
this._mapSourceControls = createMapSourceControls({
container: this._mapStackChips,
statusElement: this._mapStackStatus,
@@ -8900,8 +8901,8 @@ export class StyleManager {
/** Wire the top-center action that clears only manager-owned data layers. */
_initClearSelectedLayersButton() {
if (!this._clearSelectedLayersBtn) return;
this._clearSelectedLayersHandler = () => { void this.clearSelectedLayers(); };
this._clearSelectedLayersBtn.addEventListener('click', this._clearSelectedLayersHandler);
this._clearLayersControl?.destroy();
this._clearLayersControl = bindClearLayersControl(this._clearSelectedLayersBtn, () => this.clearSelectedLayers());
}
/**
@@ -8928,9 +8929,7 @@ export class StyleManager {
this._preservePanelStateDuringLayerClear = true;
this._syncContextModeButtons();
this._userFacingContextNotificationTokens.add(notificationToken);
this._clearSelectedLayersBtn.setAttribute('aria-disabled', 'true');
this._clearSelectedLayersBtn.setAttribute('aria-busy', 'true');
this._clearSelectedLayersBtn.setAttribute('aria-label', 'Clearing selected data layers');
this._clearLayersControl?.setBusy(true);
const managerOperation = this._dataManager.clearSelectedLayers({
origin: 'user',
@@ -8962,9 +8961,7 @@ export class StyleManager {
this._contextModeChanging = false;
this._syncContextModeButtons();
}
this._clearSelectedLayersBtn.setAttribute('aria-disabled', 'false');
this._clearSelectedLayersBtn.setAttribute('aria-busy', 'false');
this._clearSelectedLayersBtn.setAttribute('aria-label', 'Clear selected data layers');
this._clearLayersControl?.setBusy(false);
this._preservePanelStateDuringLayerClear = false;
this._clearSelectedLayersManagerPromise = null;
this._clearSelectedLayersPromise = null;
@@ -9377,6 +9374,7 @@ export class StyleManager {
this._applicationShortcuts?.destroy();
this._displayControls?.destroy();
this._mapSourceControls?.destroy();
this._clearLayersControl?.destroy();
this._visualEffects.stop();
this._styleParameters?.destroy();
for (const control of this._panelDisclosureControls || []) control.destroy();
@@ -9466,10 +9464,7 @@ export class StyleManager {
this._cockpitResetGlobeBtn?.removeEventListener('click', this._globeResetHandler);
this._globeResetHandler = null;
}
if (this._clearSelectedLayersBtn && this._clearSelectedLayersHandler) {
this._clearSelectedLayersBtn.removeEventListener('click', this._clearSelectedLayersHandler);
this._clearSelectedLayersHandler = null;
}
this._cctvUnsubscribe?.();
this._cctvUnsubscribe = null;
this._commandDockTrayObserver?.disconnect?.();