mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52:21 +00:00
Keep the saved Satellites state when Satellites is still busy as Space Missions turns off
When Satellites had not settled within the 30 s limit, turning Space Missions off cleared the saved Satellites state and put the parameters back before failing, so Satellites stayed on as Space Missions had switched it with nothing left to retry. Now a busy Satellites layer is left untouched and the saved state is kept, so turning Space Missions off again finishes the restore. A Satellites action the person took still gets its parameters back. Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
1 parent
46e831620e
commit
ee37511332
4 files changed
+52
-7
No files matched your search
@@ -623,6 +623,13 @@ test('a Satellites enable that never settles still lets mission disable complete
|
||||
stuck.resolve();
|
||||
}
|
||||
await f.settle();
|
||||
// The saved Satellites state was kept: turning Space Missions off again
|
||||
// once Satellites settles gives back the Satellites it turned on.
|
||||
assert.equal(f.manager.isEnabled('satellites'), true);
|
||||
await f.manager.setEnabled('rocket-launches', false, { origin: 'user' });
|
||||
await f.settle();
|
||||
assert.equal(f.manager.isEnabled('rocket-launches'), false);
|
||||
assert.equal(f.manager.isEnabled('satellites'), false);
|
||||
});
|
||||
|
||||
test('a failed Satellites restore still clears the selected mission panel', async (t) => {
|
||||
|
||||
@@ -179,18 +179,21 @@ export function createIngestion({
|
||||
layerState._satelliteStateBeforeMission !== snapshot
|
||||
)
|
||||
return;
|
||||
// An accepted Satellites action owns visibility through mission teardown.
|
||||
const restoreVisibility = snapshot.restoreVisibility !== false;
|
||||
// Satellites is still busy: change nothing and keep the saved state, so
|
||||
// turning Space Missions off again can finish the restore.
|
||||
if (restoreVisibility && !idle)
|
||||
throw new Error(
|
||||
'Space Missions could not restore the satellites layer: it did not settle',
|
||||
);
|
||||
layerState._satelliteStateBeforeMission = null;
|
||||
layerState._satelliteActivationPromise = null;
|
||||
manager.setLayerParams(
|
||||
'satellites',
|
||||
parts.policyHelpers.satelliteParamsAfterSpaceMissions(snapshot.params),
|
||||
);
|
||||
// An accepted Satellites action owns visibility through mission teardown.
|
||||
if (snapshot.restoreVisibility === false) return;
|
||||
if (!idle)
|
||||
throw new Error(
|
||||
'Space Missions could not restore the satellites layer: it did not settle',
|
||||
);
|
||||
if (!restoreVisibility) return;
|
||||
const restored = await manager.setEnabled('satellites', snapshot.enabled);
|
||||
if (
|
||||
restored === false ||
|
||||
|
||||
@@ -177,3 +177,36 @@ test('without a Satellites action the exit restores the pre-mission visibility',
|
||||
['enabled', 'satellites', false],
|
||||
]);
|
||||
});
|
||||
|
||||
test('a Satellites layer that does not settle keeps the saved state for the next exit', async () => {
|
||||
const r = satelliteRig({ enabledBefore: false });
|
||||
let idle = false;
|
||||
r.state._dataManager.waitForLayerIdle = async () => idle;
|
||||
await assert.rejects(
|
||||
r.ingestion.restoreSatelliteDependency(),
|
||||
/did not settle/,
|
||||
);
|
||||
assert.deepEqual(r.calls, [], 'nothing changes while Satellites is busy');
|
||||
assert.deepEqual(r.state._satelliteStateBeforeMission, {
|
||||
enabled: false,
|
||||
params: { mode: 'before' },
|
||||
});
|
||||
|
||||
// Turning Space Missions off again once Satellites settles finishes it.
|
||||
idle = true;
|
||||
await r.ingestion.restoreSatelliteDependency();
|
||||
assert.deepEqual(r.calls, [
|
||||
['params', 'satellites', { mode: 'before' }],
|
||||
['enabled', 'satellites', false],
|
||||
]);
|
||||
assert.equal(r.state._satelliteStateBeforeMission, null);
|
||||
});
|
||||
|
||||
test('a Satellites action the person took still gets its parameters back when Satellites is busy', async () => {
|
||||
const r = satelliteRig({ enabledBefore: false });
|
||||
r.state._dataManager.waitForLayerIdle = async () => false;
|
||||
r.state._satelliteStateBeforeMission.restoreVisibility = false;
|
||||
await r.ingestion.restoreSatelliteDependency();
|
||||
assert.deepEqual(r.calls, [['params', 'satellites', { mode: 'before' }]]);
|
||||
assert.equal(r.state._satelliteStateBeforeMission, null);
|
||||
});
|
||||
Reference in new issue
Block a user