mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Properly log meal diary entries
This commit is contained in:
@@ -66,6 +66,7 @@ class Log {
|
||||
|
||||
Log.fromMealItem(MealItem mealItem) {
|
||||
this.ingredientId = mealItem.ingredientId;
|
||||
this.ingredientObj = mealItem.ingredientObj;
|
||||
this.weightUnit = null;
|
||||
this.amount = mealItem.amount;
|
||||
}
|
||||
|
||||
@@ -268,10 +268,13 @@ class Nutrition extends WgerBaseProvider with ChangeNotifier {
|
||||
//var meal = findMealById(mealId);
|
||||
for (var item in meal.mealItems) {
|
||||
Log log = Log.fromMealItem(item);
|
||||
log.planId = findById(meal.plan).id;
|
||||
final plan = findById(meal.plan);
|
||||
log.planId = plan.id;
|
||||
log.datetime = DateTime.now();
|
||||
|
||||
await post(log.toJson(), makeUrl(_nutritionDiaryPath));
|
||||
final data = await post(log.toJson(), makeUrl(_nutritionDiaryPath));
|
||||
log.id = data['id'];
|
||||
plan.logs.add(log);
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user