Skip to content

Commit

Permalink
Clear out existing models on load to avoid conflicts when reloading data
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Jan 13, 2017
1 parent da86822 commit 36324ea
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/app/reducers/entitiesReducer.js
Expand Up @@ -14,6 +14,13 @@ export function loadData(state, payload) {

const {pilots, designs, mechs} = payload;

// Clear out any existing models from state so that we can avoid
// conflicts from the new data coming in if data is reloaded
[Pilot, Mech, MechDesign].forEach(modelType => {
modelType.all().withModels.forEach(model => model.delete());
session.state = session.reduce();
});

// Queue up creation commands for each entry
pilots.forEach(pilot => Pilot.parse(pilot));
designs.forEach(design => MechDesign.parse(design));
Expand Down

0 comments on commit 36324ea

Please sign in to comment.