Skip to content

Commit

Permalink
🐛⚡️Fixed checkRules
Browse files Browse the repository at this point in the history
  • Loading branch information
carefree0910 committed May 25, 2023
1 parent eb31351 commit 26f560a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cfdraw/.web/src/plugins/utils/renderFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ function checkConstraint(
if (constraint === "singleNode") return !["group", "multiple", "none"].includes(info.type);
return info.type === constraint;
}
async function checkRules(
function checkRules(
rules: NodeConstraintSettings["nodeConstraintRules"],
info?: IResponse,
): Promise<boolean> {
): boolean {
if (rules?.some) {
for (const nodeConstraint of rules.some) {
if (await useNodeFilter({ nodeConstraint })(info)) return true;
if (checkConstraint(nodeConstraint, info)) return true;
}
return false;
}
if (rules?.every) {
for (const nodeConstraint of rules.every) {
if (!(await useNodeFilter({ nodeConstraint })(info))) return false;
if (!checkConstraint(nodeConstraint, info)) return false;
}
return true;
}
Expand Down Expand Up @@ -98,7 +98,7 @@ export function useNodeFilter(
): (info?: IResponse) => Promise<boolean> {
return useCallback(async (info) => {
if (!checkConstraint(settings.nodeConstraint, info)) return false;
if (!(await checkRules(settings.nodeConstraintRules, info))) return false;
if (!checkRules(settings.nodeConstraintRules, info)) return false;
if (!(await checkValidator(settings.nodeConstraintValidator, info))) return false;
return true;
}, useConstraintDeps(settings));
Expand Down

0 comments on commit 26f560a

Please sign in to comment.