Open
Conversation
marcos-diaz
reviewed
Aug 11, 2025
| case 'PAD_ENTER': return '↵' | ||
| case 'PAD_PERIOD': return '.' | ||
| } | ||
| if (key.startsWith('PAD_')) return key.slice('PAD_'.length) |
Contributor
There was a problem hiding this comment.
.slice('PAD_'.length)
This approach is harder to understand at first glance, rather than simply splitting by _
marcos-diaz
reviewed
Aug 11, 2025
| switch (hid) { | ||
| case 'KEY_SPACE': | ||
| icon = 'space_bar' | ||
| break |
Contributor
There was a problem hiding this comment.
This is the reason I try to avoid switch in JS, too much syntax noise for a minimal (negligible) performance gain.
marcos-diaz
reviewed
Aug 11, 2025
| if (label.startsWith('KEY_')) { | ||
| const key = label.slice('KEY_'.length) | ||
| switch (key) { | ||
| case 'ESCAPE': return 'Esc' |
Contributor
There was a problem hiding this comment.
I like these (because they do not need break)
marcos-diaz
reviewed
Aug 11, 2025
| if (this.section instanceof CtrlButton) { | ||
| if (index==1 && this.section.hold) cls += ' hold' | ||
| if (index==2 && this.section.double) cls += ' double' | ||
| if (index == 1 && this.section.hold) cls += ' hold' |
marcos-diaz
reviewed
Aug 11, 2025
| const icon = this.getIcon(action) | ||
| const cls = this.getClass(0, action, text, icon) | ||
| return {cls, text, icon} | ||
| return { cls, text, icon } |
Contributor
There was a problem hiding this comment.
This flavor of linting is up to personal preference
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I found that the
getTextandgetIconmethods inaction_preview.tsuse a lot ofifjudgments. I think changing them toswitchwill make them more efficient.