forked from eatvio/eatvio_app
fix(diary): some fixes offline-diary
This commit is contained in:
@@ -156,7 +156,14 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
}
|
||||
} catch (e, st) {
|
||||
await reportFrom(e, st, this);
|
||||
log(e.toString());
|
||||
log('updateCurrentDiary error: $e');
|
||||
// BUG-1 fix: офлайн fallback — перезагружаем из кэша, чтобы UI
|
||||
// отразил изменения, выполненные пользователем.
|
||||
try {
|
||||
await fetchDiaryV2(needLoading: false, diaryId: diaryId);
|
||||
} catch (_) {
|
||||
// Не критично — UI останется на текущем состоянии
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,8 +358,9 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
planDuration = chosenPlanModel.plan.duration;
|
||||
planName = chosenPlanModel.plan.name;
|
||||
currentPlanDay = consultantReview.currentPlanDay;
|
||||
} catch (_) {
|
||||
// Офлайн — данные плана недоступны
|
||||
} catch (e) {
|
||||
// BUG-9 fix: офлайн — данные плана недоступны, логируем для отладки
|
||||
log('[setDiary] Plan/comments data unavailable (offline?): $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,7 +439,11 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
required int quantity,
|
||||
int? productNutritionalValueId,
|
||||
}) async {
|
||||
emit((state as DiaryStateLoaded).copyWith(isLoadingAddingProductInMeal: true));
|
||||
// BUG-2 fix: безопасная проверка типа стейта перед кастом
|
||||
final currentState = state;
|
||||
if (currentState is DiaryStateLoaded) {
|
||||
emit(currentState.copyWith(isLoadingAddingProductInMeal: true));
|
||||
}
|
||||
try {
|
||||
await diaryRepository.addPortionToMeal(
|
||||
diaryId: diaryId,
|
||||
|
||||
Reference in New Issue
Block a user