Progress on dependency updates

This commit is contained in:
Stefan Zermatten
2022-05-09 16:32:15 +02:00
parent caf50d1578
commit 23fa6fe634
6 changed files with 159 additions and 21 deletions

View File

@@ -84,12 +84,12 @@ const DenormalisedOnlyCreaturePropertySchema = new SimpleSchema({
},
// Dependency tree, the ID of the lowest ordered doc connected to this doc
// via dependencies
/*depGroupId: {
depGroupId: {
type: String,
regEx: SimpleSchema.RegEx.Id,
index: 1,
removeBeforeCompute: true,
}*/
},
});
CreaturePropertySchema.extend(DenormalisedOnlyCreaturePropertySchema);

View File

@@ -4,7 +4,7 @@ import SimpleSchema from 'simpl-schema';
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js';
import { assertEditPermission } from '/imports/api/sharing/sharingPermissions.js';
import { computeCreatureDependencyGroup } from '/imports/api/engine/computeCreature.js';
import computeCreature, { computeCreatureDependencyGroup } from '/imports/api/engine/computeCreature.js';
const damageProperty = new ValidatedMethod({
name: 'creatureProperties.damage',
@@ -37,9 +37,13 @@ const damageProperty = new ValidatedMethod({
`Property of type "${property.type}" can't be damaged`
);
}
let result = damagePropertyWork({property, operation, value});
// Dependencies can't be changed through damage, only recompute deps
computeCreatureDependencyGroup(property);
let result = damagePropertyWork({ property, operation, value });
if (property.depGroupId) {
// Dependencies can't be changed through damage, only recompute deps
computeCreatureDependencyGroup([property.depGroupId], rootCreature._id);
} else {
computeCreature(rootCreature._id);
}
return result;
},
});