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

Kiosk: fixing time=0 bug #6012

Merged
merged 3 commits into from
Aug 10, 2023
Merged

Kiosk: fixing time=0 bug #6012

merged 3 commits into from
Aug 10, 2023

Conversation

srietkerk
Copy link
Contributor

For the time flag, I made sure that the user couldn't specify higher than 240, but didn't check the floor. The regex allows the time=0 to pass through, and right now, it makes the UI kinda freak out. It wasn't apparent to me whether or not it was making a lot of requests to the backend at the time, but either way, it's something to be fixed.

We don't want time=0 to be possible, so I've made it so that if time=0 is specified, it will just resort to the default.

One thing to note as this change will still allow time entries like 024 or any number that starts with 0 or 00. It will just take the value of the first non-zero numbers. For example, 024 just resulted in a 24 hour code. Something like 001 will just result in an hour long code.

I know we can limit this with the regex by making it so leading zeros aren't valid; this will just make the timeout the default 30 minutes.

I don't have a strong preference for one over the other, but the zero check is the first solution I thought of.

@srietkerk srietkerk requested a review from a team August 8, 2023 23:26
@eanders-ms
Copy link
Contributor

You mention this is a user supplied value. Can it be negative? Can it parse to NaN?

@srietkerk
Copy link
Contributor Author

You mention this is a user supplied value. Can it be negative? Can it parse to NaN?

@eanders-ms, no, it can't be negative because of the regex. If the user passes in something like -1 or (x+5) or anything that is not a number after the equal sign first, it will be viewed as an invalid entry. If a user input something like time=0-1, the regex would only take the 0.

Copy link
Member

@jwunderl jwunderl left a comment

Choose a reason for hiding this comment

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

behavior change lgtm but I'd lean towards avoiding nested ternaries when it's easy~

kiosk/src/Components/AddingGame.tsx Outdated Show resolved Hide resolved
@srietkerk srietkerk merged commit adca592 into master Aug 10, 2023
@srietkerk srietkerk deleted the srietkerk-kiosk-time-0 branch August 10, 2023 18:17
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.

4 participants