diff --git a/packages/smooth_app/lib/data_models/up_to_date_changes.dart b/packages/smooth_app/lib/data_models/up_to_date_changes.dart index d46cf4df2f7..050964bdd47 100644 --- a/packages/smooth_app/lib/data_models/up_to_date_changes.dart +++ b/packages/smooth_app/lib/data_models/up_to_date_changes.dart @@ -80,7 +80,10 @@ class UpToDateChanges { if (change.noNutritionData != null) { initial.noNutritionData = change.noNutritionData; } - if (change.nutriments != null) { + // cf. https://github.com/openfoodfacts/smooth-app/issues/4627 + // If we don't check if nutriments is empty, most of the time we overwrite + // potentially existing nutriments with an empty map. + if (change.nutriments != null && !change.nutriments!.isEmpty()) { initial.nutriments = change.nutriments; } if (change.servingSize != null) { diff --git a/packages/smooth_app/lib/pages/product/ordered_nutrients_cache.dart b/packages/smooth_app/lib/pages/product/ordered_nutrients_cache.dart index 26815d4989f..9bbdf121a0b 100644 --- a/packages/smooth_app/lib/pages/product/ordered_nutrients_cache.dart +++ b/packages/smooth_app/lib/pages/product/ordered_nutrients_cache.dart @@ -24,7 +24,7 @@ class OrderedNutrientsCache { cache._orderedNutrients = await cache._get(); if (cache._orderedNutrients == null) { if (context.mounted) { - await LoadingDialog.run( + cache._orderedNutrients = await LoadingDialog.run( context: context, future: cache._download(), );