diff --git a/src/layers/launches/failedEntry.test.mjs b/src/layers/launches/failedEntry.test.mjs index 1458da4670..19d6c7aaa2 100644 --- a/src/layers/launches/failedEntry.test.mjs +++ b/src/layers/launches/failedEntry.test.mjs @@ -670,6 +670,44 @@ test('Space Missions turned on again after a busy restore switches Satellites on assert.equal(f.manager.isEnabled('satellites'), false); }); +test('a Satellites switch made between missions is what the next mission gives back', async (t) => { + const f = await fixture(t); + f.upstream.status = 200; + assert.equal( + await f.manager.setEnabled('rocket-launches', true, { origin: 'user' }), + true, + ); + await f.settle(); + f.state.satelliteSettleTimeoutMs = 50; + const satellites = f.manager.layers.get('satellites').module; + const enable = satellites.enable; + const stuck = Promise.withResolvers(); + satellites.enable = () => stuck.promise; + try { + await f.manager.setEnabled('satellites', false); + void f.manager.setEnabled('satellites', true); + await f.manager.setEnabled('rocket-launches', false, { origin: 'user' }); + } finally { + satellites.enable = enable; + stuck.resolve(); + } + await f.settle(); + // The person switches Satellites on, then something else switches it off. + await f.manager.setEnabled('satellites', true, { origin: 'user' }); + await f.settle(); + await f.manager.setEnabled('satellites', false); + await f.settle(); + assert.equal( + await f.manager.setEnabled('rocket-launches', true, { origin: 'user' }), + true, + ); + await f.settle(); + assert.equal(f.manager.isEnabled('satellites'), true); + await f.manager.setEnabled('rocket-launches', false, { origin: 'user' }); + await f.settle(); + assert.equal(f.manager.isEnabled('satellites'), false); +}); + test('a failed Satellites restore still clears the selected mission panel', async (t) => { const f = await fixture(t); f.upstream.status = 200; diff --git a/src/layers/launches/ingestion.js b/src/layers/launches/ingestion.js index 58135ad991..9b7de0e633 100644 --- a/src/layers/launches/ingestion.js +++ b/src/layers/launches/ingestion.js @@ -129,8 +129,16 @@ export function createIngestion({ return; // A saved state kept by a restore that could not finish (Satellites was // busy) is still the one from before the mission: keep it, and switch - // Satellites on for the mission again. - if (!layerState._satelliteStateBeforeMission) + // Satellites on for the mission again. A Satellites switch the person + // made since (restoreVisibility false) settled its visibility, so it + // is taken as it is now; its params are still the saved ones. + const kept = layerState._satelliteStateBeforeMission; + if (kept?.restoreVisibility === false) + layerState._satelliteStateBeforeMission = { + enabled: manager.isEnabled('satellites'), + params: kept.params, + }; + else if (!kept) layerState._satelliteStateBeforeMission = { enabled: manager.isEnabled('satellites'), params: parts.policyHelpers.satelliteParamsAfterSpaceMissions(