forked from eatvio/eatvio_app
feat(diary): fixed consultant portion comments and day finishing errors handling
This commit is contained in:
@@ -47,6 +47,7 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
}
|
||||
|
||||
String comment = '';
|
||||
bool commentNeedsToBeFilled = false;
|
||||
|
||||
void setInitialDate(DateTime? date) {
|
||||
if (date == null) return;
|
||||
@@ -68,7 +69,7 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
return canSelect;
|
||||
}
|
||||
|
||||
Future<bool> fetchDiaryV2({bool needLoading = false, int? diaryId, DateTime? date}) async {
|
||||
Future<bool> fetchDiaryV2({bool needLoading = false, int? diaryId}) async {
|
||||
final currentState = state;
|
||||
try {
|
||||
if (needLoading) {
|
||||
@@ -283,9 +284,15 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> finishDiaryDay({required int diaryId, required String wakeUp, required String retire}) async {
|
||||
await diaryRepository.finishDiaryDay(diaryId: diaryId, wakeUp: wakeUp, retire: retire, comment: comment.isEmpty ? null : comment);
|
||||
await updateCurrentDiary();
|
||||
Future<bool> finishDiaryDay({required int diaryId, required String wakeUp, required String retire}) async {
|
||||
try {
|
||||
await diaryRepository.finishDiaryDay(diaryId: diaryId, wakeUp: wakeUp, retire: retire, comment: comment.isEmpty ? null : comment);
|
||||
await updateCurrentDiary();
|
||||
return true;
|
||||
} catch (e, st) {
|
||||
log(e.toString(), stackTrace: st);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<NutritionDataModel> getNutrition(int index) async {
|
||||
@@ -422,6 +429,7 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
|
||||
void fillComment(String comment) {
|
||||
this.comment = comment;
|
||||
commentNeedsToBeFilled = comment.isNotEmpty && comment.length < 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user