-
-
Notifications
You must be signed in to change notification settings - Fork 447
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
fix: "No nutrition facts" switch not working as intended #4583
fix: "No nutrition facts" switch not working as intended #4583
Conversation
@@ -551,10 +555,11 @@ class ProductEditNutritionFactsFragment : ProductEditFragment() { | |||
// Add no nutrition data entry to map | |||
if (binding.checkboxNoNutritionData.isChecked) { | |||
targetMap[ApiFields.Keys.NO_NUTRITION_DATA] = "on" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we send the boolean to deactivate, but do we send the boolean to reactivate, along or before nutrients ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, this is not the case right now.
Currently in the code, the app checks if the field is null (= no nutrition data) or == "ON"
So I will just send a null in the other cases. Otherwise I am afraid of generating some bugs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should be OK right now, with the new commit #9ce02dd
… the rest of the UI shouldn't be displayed + no other field sent to the API
b36c782
to
9ce02dd
Compare
@@ -575,6 +575,10 @@ class ProductEditNutritionFactsFragment : ProductEditFragment() { | |||
targetMap += getNutrientMapIfUpdated(view) | |||
} | |||
|
|||
// We force a null value here for "no nutrition", instead of an "off" String, | |||
// to be sure to do not break other apps | |||
targetMap[ApiFields.Keys.NO_NUTRITION_DATA] = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look at line 335, on Android the check is if != null -> true
I have improved the checks to ensure, "on" is true and everything else is false
The code should now be OK with comments from openfoodfacts/api-documentation#70 |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
thank you @g123k , merging and releasing to internal 👍 |
PR that fixes two issues:
#4582