Open Dieterbe opened 6 months ago
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.
spoke with roland, who basically said that basically, the app is not designed to be in sync with the backend to that extent :sweat_smile:
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: