Skip to content
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

[#10917] Fix unexpected behaviour when reverting to template feedback path #10975

Merged
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -246,15 +246,26 @@ export class QuestionEditFormComponent implements OnInit {
if (allowedRecipientTypes.indexOf(recipientType) === -1) {
newRecipientType = allowedRecipientTypes[0];
}
this.triggerModelChangeBatch({
giverType,
recipientType: newRecipientType,
commonVisibilitySettingName: 'Please select a visibility option',
isUsingOtherVisibilitySetting: false,
showResponsesTo: [],
showGiverNameTo: [],
showRecipientNameTo: [],
});
if (this.model.giverType === giverType && this.model.recipientType === newRecipientType) {
// do not reset the visibility settings if reverting feedback path to preset template provided
if (this.model.isUsingOtherFeedbackPath) {
Comment on lines +249 to +251
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is perhaps not a good practice to have two such if's as they create an arrow-antipattern. You might want to just do

Suggested change
if (this.model.giverType === giverType && this.model.recipientType === newRecipientType) {
// do not reset the visibility settings if reverting feedback path to preset template provided
if (this.model.isUsingOtherFeedbackPath) {
if (this.model.giverType === giverType && this.model.recipientType === newRecipientType
&& this.model.isUsingOtherFeedbackPath) {

in which the precedence of the booleans achieves the exact same effect.

Copy link
Contributor

@moziliar moziliar Apr 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong logic above^. Shouldn't omit the path where the function does nothing

// remove the custom feedback if selecting a common feedback path
this.triggerModelChangeBatch({
isUsingOtherFeedbackPath: false,
});
}
} else {
this.triggerModelChangeBatch({
giverType,
recipientType: newRecipientType,
commonVisibilitySettingName: 'Please select a visibility option',
isUsingOtherFeedbackPath: false,
isUsingOtherVisibilitySetting: false,
showResponsesTo: [],
showGiverNameTo: [],
showRecipientNameTo: [],
});
}
}

/**
Expand Down