From 39a512193e7c6099bd136c4afa5ff023f43d7173 Mon Sep 17 00:00:00 2001 From: Anatoliy Poloz Date: Fri, 16 Oct 2026 21:12:40 +0300 Subject: [PATCH 1/2] fix(diary): parse commented_from_diet/reviewed_from_diet portion states, fallback unknown states to PortionState.unknown --- .../diary/models/diary_day_model.dart | 7 +++- .../diary/models/diary_day_model_test.dart | 36 ++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/lib/features/diary/models/diary_day_model.dart b/lib/features/diary/models/diary_day_model.dart index c602111f..76a353d9 100644 --- a/lib/features/diary/models/diary_day_model.dart +++ b/lib/features/diary/models/diary_day_model.dart @@ -18,8 +18,13 @@ enum PortionState { @JsonValue('eaten_edited') eatenEdited, commented, + @JsonValue('commented_from_diet') + commentedFromDiet, @JsonValue('reviewed_by_user') reviewedByUser, + @JsonValue('reviewed_from_diet') + reviewedFromDiet, + unknown, } @freezed @@ -138,7 +143,7 @@ abstract class PortionModel with _$PortionModel { @JsonKey(name: "quantity") required int quantity, @JsonKey(name: "portion") required String portion, @JsonKey(name: "from_diet") required bool fromDiet, - @JsonKey(name: "state") required PortionState portionState, + @JsonKey(name: "state", unknownEnumValue: PortionState.unknown) required PortionState portionState, }) = _PortionModel; factory PortionModel.fromJson(Map json) => _$PortionModelFromJson(json); diff --git a/test/features/diary/models/diary_day_model_test.dart b/test/features/diary/models/diary_day_model_test.dart index 76592cfd..8de1266d 100644 --- a/test/features/diary/models/diary_day_model_test.dart +++ b/test/features/diary/models/diary_day_model_test.dart @@ -4,14 +4,48 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('PortionState enum', () { test('has all expected values', () { - expect(PortionState.values.length, 7); + expect(PortionState.values.length, 10); expect(PortionState.filledDiet, isNotNull); expect(PortionState.eatenFromDiet, isNotNull); expect(PortionState.eaten, isNotNull); expect(PortionState.eatenDeleted, isNotNull); expect(PortionState.eatenEdited, isNotNull); expect(PortionState.commented, isNotNull); + expect(PortionState.commentedFromDiet, isNotNull); expect(PortionState.reviewedByUser, isNotNull); + expect(PortionState.reviewedFromDiet, isNotNull); + expect(PortionState.unknown, isNotNull); + }); + }); + + group('PortionModel.fromJson', () { + Map portionJson({required String state}) => { + 'id': 1, + 'product_nutritional_value_id': null, + 'product_calories_info': null, + 'product_name': 'Oatmeal', + 'quantity': 1, + 'portion': '100g', + 'from_diet': true, + 'state': state, + }; + + test('parses commented_from_diet state', () { + final model = PortionModel.fromJson(portionJson(state: 'commented_from_diet')); + + expect(model.portionState, PortionState.commentedFromDiet); + }); + + test('parses reviewed_from_diet state', () { + final model = PortionModel.fromJson(portionJson(state: 'reviewed_from_diet')); + + expect(model.portionState, PortionState.reviewedFromDiet); + }); + + test('does not throw on unknown state from backend', () { + final model = PortionModel.fromJson(portionJson(state: 'some_future_state')); + + expect(model.portionState, PortionState.unknown); }); }); From d3336b1263aa658cd15d46015695fd0fb8fc7ce4 Mon Sep 17 00:00:00 2001 From: Anatoliy Poloz Date: Mon, 19 Oct 2026 10:48:32 +0300 Subject: [PATCH 2/2] bump version for TF --- pubspec.yaml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 088eb5eb..f9269c80 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: eatvio_app description: A new Flutter project. -version: 1.3.55+144 -publish_to: 'none' +version: 1.3.56+145 +publish_to: "none" environment: sdk: ^3.10.4 @@ -175,14 +175,14 @@ flutter_intl: flutter_native_splash: android: true ios: true - color: '#FFFFFF' - image_android: 'assets/splash/splash.png' - image_dark_android: 'assets/splash/splash.png' - image_ios: 'assets/splash/splash.png' - image_dark_ios: 'assets/splash/splash.png' - branding_android: 'assets/splash/branding.png' - branding_dark_android: 'assets/splash/branding.png' + color: "#FFFFFF" + image_android: "assets/splash/splash.png" + image_dark_android: "assets/splash/splash.png" + image_ios: "assets/splash/splash.png" + image_dark_ios: "assets/splash/splash.png" + branding_android: "assets/splash/branding.png" + branding_dark_android: "assets/splash/branding.png" android_12: - image: 'assets/splash/splash.png' - image_dark: 'assets/splash/splash.png' - branding: 'assets/splash/branding.png' + image: "assets/splash/splash.png" + image_dark: "assets/splash/splash.png" + branding: "assets/splash/branding.png"