Fix empty preconditions not firing

This commit is contained in:
Zaid Abdulla committed 2019-06-16 02:24:22 -07:00
1 parent e57d73267e
commit 9ba078870a
1 file changed
+10 -8
+10 -8
View File
@@ -158,15 +158,17 @@ async function fetchPresets(): Promise<Preset[]> {
}
const events = preset["events"] || {};
let precondition;
try {
precondition = parse(preset["precondition"]);
} catch (error) {
precondition = mongoQueryToFilter(JSON.parse(preset["precondition"]));
}
let precondition = true as Expression;
if (preset["precondition"]) {
try {
precondition = parse(preset["precondition"]);
} catch (error) {
precondition = mongoQueryToFilter(JSON.parse(preset["precondition"]));
}
// Simplify expression
precondition = expression.evaluate(precondition);
// Simplify expression
precondition = expression.evaluate(precondition);
}
const _provisions = preset["provisions"] || [];