-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor: Refactor makeResult function and form handling in Trial component #1254
Conversation
|
||
const breakRoundOn = config.break_round_on; | ||
const shouldBreakRound = breakRoundOn && checkBreakRound(form.map((formElement) => formElement.value), breakRoundOn); | ||
const shouldCallOnNextInOnResult = !shouldBreakRound |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we can even lose this variable, as the docstring below actually already explains why a boolean is passed into the onResult
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we change this to:
const shouldBreakRound = breakRoundConditions && checkBreakRound(form.map((formElement) => formElement.value), breakRoundConditions);
const shouldCallOnNextInOnResult = !shouldBreakRound
await onResult(
{
decision_time: getAndStoreDecisionTime(),
form,
config
},
false,
false // We already call `onNext` _after_ `onResult` as we cannot pass the `shouldBreak` param `onResult`'s `onNext` call.
);
onNext(shouldBreakRound);
…m` check as form is only utilized from within that if statement
…_form` is always defined here
8488fcc
to
00c3e63
Compare
This pull request includes several refactorings in the Trial component. The
checkBreakRound
function has been refactored to use explicit types for parameters. The handling of theform
variable has been moved inside thefeedback_form
check, as it is only utilized from within that if statement. The assignment ofform
has been simplified, and it is now initialized as an empty array if undefined. Additionally, there is a fix for assertions in tests.Basically, the scenarios are now as follows (in chronological order):
onResult
onNext
Resolves #1245