Permalink
Browse files

Clear out existing models on load to avoid conflicts when reloading data

  • Loading branch information...
markerikson committed Jan 7, 2017
1 parent da86822 commit 36324ea46ae1f0fcda44816c3820c255a82aa5a8
Showing with 7 additions and 0 deletions.
  1. +7 −0 src/app/reducers/entitiesReducer.js
@@ -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));

0 comments on commit 36324ea

Please sign in to comment.