Skip to content

Commit

Permalink
Fixes an issue where software panels disappear from the simulator whe…
Browse files Browse the repository at this point in the history
…n the flight is reset. Closes #2558
  • Loading branch information
alexanderson1993 committed Sep 21, 2021
1 parent 37988ef commit e023f44
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions server/typeDefs/flight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const aspectList = [

export function addAspects(template, sim: Classes.Simulator, data = App) {
// Duplicate all of the other stuff attached to the simulator too.

aspectList.forEach(aspect => {
if (
aspect === "softwarePanels" ||
Expand Down Expand Up @@ -461,11 +462,25 @@ const resolver = {
newSim.template = false;
newSim.templateId = tempId;
newSim.mission = sim.mission;
newSim.stations = sim.stations;
newSim.stations = sim.stations.map(
s =>
new Classes.Station({
...s,
cards: s.cards.map(c => {
const panelIndex = sim.panels.indexOf(c.component);
if (panelIndex > -1) {
return new Classes.Card({
...c,
component: newSim.panels[panelIndex],
});
}
return new Classes.Card({...c});
}),
}),
);
newSim.executedTimelineSteps = [];
newSim.clientCards = {};
newSim.stationAssignedCards = {};

newSim.stationSet = sim.stationSet;
const stationSet = App.stationSets.find(
s => s.id === newSim.stationSet,
Expand All @@ -489,7 +504,7 @@ const resolver = {
),
);
App.simulators.push(newSim);
addAspects({simulatorId: tempId}, newSim);
addAspects({simulatorId: tempId}, newSim, App);
// Create exocomps for the simulator
App.handleEvent(
{simulatorId: newSim.id, count: newSim.exocomps},
Expand Down

0 comments on commit e023f44

Please sign in to comment.