Skip to content

Commit

Permalink
refactor: Simplify break round condition in Trial component
Browse files Browse the repository at this point in the history
  • Loading branch information
drikusroor committed Sep 9, 2024
1 parent 00c3e63 commit e194bec
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions frontend/src/components/Trial/Trial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,8 @@ const Trial = (props: TrialProps) => {
form.map((formElement => (formElement.value = formElement.value || '')))
}

const breakRoundOn = config.break_round_on;
const shouldBreakRound = breakRoundOn && checkBreakRound(form.map((formElement) => formElement.value), breakRoundOn);
const shouldCallOnNextInOnResult = !shouldBreakRound
const breakRoundConditions = config.break_round_on;
const shouldBreakRound = breakRoundConditions && checkBreakRound(form.map((formElement) => formElement.value), breakRoundConditions);

await onResult(
{
Expand All @@ -106,8 +105,9 @@ const Trial = (props: TrialProps) => {
config
},
false,
// if we break the round, we don't want to call onNext in onResult
shouldCallOnNextInOnResult
// if we break the round, we don't want to call `onNext` in `onResult`
// as it does not allow us to pass a `breakRound` flag
!shouldBreakRound
);

if (shouldBreakRound) {
Expand Down

0 comments on commit e194bec

Please sign in to comment.