Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Fixed the bug where the rating couldn't be zero. #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fixed the bug where the rating couldn't be zero. #134

wants to merge 1 commit into from

Conversation

CelerityAbbottPC
Copy link

Review on Reviewable

@darrencarlton
Copy link
Contributor

Hi Celebrity:

Thanks for the pull request. I'm not 100% sure that this is a bug.

Let's say that a recipe in the JSON array specifies 0 as the rating. That is, a recipe starts out with a rating of 0.

The starChar method will do the right thing:
String starChar(int star) =>
rating == null || star > rating ? _STAR_OFF_CHAR : _STAR_ON_CHAR;

It returns _STAR_OFF_CHAR for each star because rating is less than even the lowest star int. (The stars[] always starts at 1.)

Now if a user clicks the first star and invokes handleClick(), "star == 1 && rating == 1" evaluates to false, so the method sets rating to 1 (the value of the first star).

void handleClick(int star) {
rating = (star == 1 && rating == 1) ? 0 : star;
}

What were you seeing that seemed like a bug?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy