feat: diary time of meal

This commit is contained in:
Alex
2024-12-01 23:33:42 +03:00
parent 7e0ca28ede
commit d2c2d4d479
3 changed files with 14 additions and 23 deletions

View File

@@ -26,7 +26,7 @@ class DiaryCubit extends Cubit<DiaryState> {
setSelectedDay(DateTime day) async {
selectedDay = day;
await fetchDiary();
await fetchDiary(true);
}
setSelectedMeal(int meal) {
@@ -34,9 +34,11 @@ class DiaryCubit extends Cubit<DiaryState> {
emit((state as DiaryStateLoaded).copyWith(selectedMeal: selectedMeal));
}
fetchDiary() async {
emit(const DiaryState.loading());
selectedMeal = 1;
fetchDiary([bool needLoading = false]) async {
if (needLoading) {
emit(const DiaryState.loading());
selectedMeal = 1;
}
try {
final diaryDay = await diaryRepository.getDiaryByDate('$selectedDay');
emit(
@@ -173,10 +175,11 @@ class DiaryCubit extends Cubit<DiaryState> {
required int diaryId,
required String time,
}) async {
return await diaryRepository.fillTime(
await diaryRepository.fillTime(
diaryId: diaryId,
mealId: selectedMeal,
time: time,
);
await fetchDiary();
}
}