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

broken updating of nutritional plan probably due to json decoding failing #558

Open
Dieterbe opened this issue Apr 21, 2024 · 2 comments
Open

Comments

@Dieterbe
Copy link
Contributor

Dieterbe commented Apr 21, 2024

I have discovered 2 distinct symptoms which I assume are caused by the same bug:

  1. when you change the nutritional plan on web, and then go back into the plan in flutter and the edit menu, it doesn't reflect those changes (despite the api being called and it returning the proper value). however, when you go to nutritional plans and swipe down to refresh, then it works fine again.

  2. very often, when looking at a nutritional plan, it doesn't show the meals. it seems meal will show up if they were added very recently, but then disappear

I suspect both of these are caused by an exception: inside of the nutritional plan json, the "image" field can be both set at the meal item level, but also on the ingredient_obj level inside of the meal item.
when this happens, it seems they're set to the same value. however, the one that's inside the ingredient_obj is missing the ingredient_id field, the one at the meal item level has it. furthermore fetchAndSetPlanFull() actually calls IngredientImage.fromJson() twice, once indirectly it's called inside of Ingredient.fromJson () where it looks at the image set at the ingredient level, and then once more, it overrides the ingredient image by also decoding the image set at the meal item level. it's the first one that fails, and in debug mode we can see the exception:

[log] MissingRequiredKeysException: Required keys are missing: ingredient_id
rolandgeider added a commit to wger-project/wger that referenced this issue Apr 25, 2024
The ingredient_id was missing and causing problems on the flutter app

Closes github.com/wger-project/flutter/issues/558
@Dieterbe
Copy link
Contributor Author

the json fix is live, and this fixes the 2nd symptom.
the first one is still there, so that must be due to something else. no amount of opening and closing the nutritional plan will update the state to be reflected in the edit menu. only going to the plans list view, and swiping to refresh will do that.

@Dieterbe
Copy link
Contributor Author

spoke with roland, who basically said that basically, the app is not designed to be in sync with the backend to that extent 😅

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

No branches or pull requests

1 participant