mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
Collapse the CCTV panel when the user switches CCTV off inside Contacts
Turning a layer on does not leave Contacts, so a user could turn CCTV back on inside the mode and off again; the layer was still in the session snapshot and the panel stayed open on an empty frame. The snapshot now records every layer the user switched during the session, and suspendsLayer is true only for a layer isolation switched off that the user has not touched since.
This commit is contained in:
1 parent
f29b0b2639
commit
f0ee1b95ca
4 files changed
+47
-2
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { test } from 'node:test';
|
||||
import { ContextControls } from './contextControls.js';
|
||||
import { recordContextSessionUserChange } from '../contextModePolicy.js';
|
||||
|
||||
class Button extends EventTarget {
|
||||
constructor() {
|
||||
@@ -189,3 +190,38 @@ test('a layer Context isolation switches off is suspended until the mode is left
|
||||
await controls._dataManager.setEnabled('cctv', false);
|
||||
assert.deepEqual(seen.at(-1), ['cctv', false, false]);
|
||||
});
|
||||
|
||||
test('a layer the user switches inside the mode is no longer suspended', async (t) => {
|
||||
const { controls } = fixture(t);
|
||||
const enabled = new Set(['cctv']);
|
||||
controls._dataManager = {
|
||||
layers: new Map([['cctv', {}]]),
|
||||
getEnabledLayerIds: () => [...enabled],
|
||||
getLayerParams: () => null,
|
||||
isEffectivelyEnabled: (layerId) => enabled.has(layerId),
|
||||
isEnabled: (layerId) => enabled.has(layerId),
|
||||
async setEnabled(layerId, next) {
|
||||
if (next) enabled.add(layerId);
|
||||
else enabled.delete(layerId);
|
||||
return true;
|
||||
},
|
||||
};
|
||||
controls._captureContextSessionSnapshot();
|
||||
await controls._clearLayersOutsideContextMode('flights');
|
||||
assert.equal(controls.suspendsLayer('cctv'), true);
|
||||
// Inside Contacts the user turns CCTV back on, then off again: the panel
|
||||
// must close like any other switch-off.
|
||||
for (const next of [true, false]) {
|
||||
recordContextSessionUserChange({
|
||||
snapshot: controls._contextSessionSnapshot,
|
||||
change: {
|
||||
type: 'visibility',
|
||||
origin: 'user',
|
||||
layerId: 'cctv',
|
||||
enabled: next,
|
||||
},
|
||||
effectiveContextMode: 'flights',
|
||||
});
|
||||
}
|
||||
assert.equal(controls.suspendsLayer('cctv'), false);
|
||||
});
|
||||
Reference in new issue
Block a user