Skip to content

phrasemaker.js: Bug Fix, Linting and Prettify. #2848

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

Closed
wants to merge 4 commits into from

Conversation

daksh4469
Copy link
Member

@daksh4469 daksh4469 commented Feb 16, 2021

Issue Reference: #2609
Bug:
On clicking the divide button to divide a current more in half, the widget produces the message Click on the table to add notes. every time and also re-positions the widget.

screen-capture.1.mp4

Comment on lines 1430 to 1456
if (condition === "graphicsblocks") {
if (blockLabel === "forward" || blockLabel === "back") {
for (let i = 0; i < forwardBackLabel.length; i++) {
this._pitchWheel.navItems[i].navigateFunction = __enterArgValue;
}
} else if (blockLabel === "right" || blockLabel === "left") {
for (let i = 0; i < leftRightLabel.length; i++) {
this._pitchWheel.navItems[i].navigateFunction = __enterArgValue;
}
} else if (blockLabel === "setheading") {
for (let i = 0; i < setHeadingLabel.length; i++) {
this._pitchWheel.navItems[i].navigateFunction = __enterArgValue;
}
} else if (blockLabel === "setpensize") {
for (let i = 0; i < setPenSizeLabel.length; i++) {
this._pitchWheel.navItems[i].navigateFunction = __enterArgValue;
}
} else {
for (let i = 0; i < setLabel.length; i++) {
this._pitchWheel.navItems[i].navigateFunction = __enterArgValue;
}
}
} else if (condition === "synthsblocks") {
for (let i = 0; i < valueLabel.length; i++) {
this._pitchWheel.navItems[i].navigateFunction = __enterArgValue;
}
}
Copy link
Contributor

@vaibhavdaren vaibhavdaren Feb 17, 2021

Choose a reason for hiding this comment

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

Please make this code dry.

Declare a variable => labelLength
put if else according to your conditions and set value of noteStored

Use for loop once.
Something like:-

let labelLength = 0;
if (condition === "graphicsblocks") {
            if (blockLabel === "forward" || blockLabel === "back") {
                labelLength = forwardBackLabel.length
            }
            } else if (blockLabel === "right" || blockLabel === "left") {
                labelLength = leftRightLabel.length;
            }
               ...
            //loop just once
            for (let i = 0; i < labelLength; i++) {
                this._pitchWheel.navItems[i].navigateFunction = __enterArgValue;
            }
        }
 

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, sure.

Copy link
Contributor

@vaibhavdaren vaibhavdaren left a comment

Choose a reason for hiding this comment

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

Make code dry

@daksh4469
Copy link
Member Author

Make code dry

Check this last commit. @vaibhavdaren

@daksh4469 daksh4469 changed the title phrasemaker.js: Linting and Prettify. phrasemaker.js: Bug Fix, Linting and Prettify. Feb 19, 2021
@daksh4469
Copy link
Member Author

daksh4469 commented Feb 25, 2021

Please review this @meganindya @walterbender.
Thanks.

@daksh4469
Copy link
Member Author

I believe I should close this PR as the linting is done in #2885 by @ksraj123 and those changes have been merged and add this bug fix and some changes making the code DRY in patch #2891. Please share your feedback regarding this @walterbender @meganindya.

walterbender pushed a commit that referenced this pull request May 19, 2021
@walterbender
Copy link
Member

8722780

@daksh4469 daksh4469 deleted the daksh4469-main3 branch May 19, 2021 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants