From b51c620aa178c6f5212cc015284155a9afbab575 Mon Sep 17 00:00:00 2001 From: koreatlwls Date: Sat, 29 Jun 2024 16:23:04 +0900 Subject: [PATCH] update : GetResetDailyEventUseCase --- .../daily/usecase/GetResetDailyEventUseCase.kt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/domain/daily/src/main/kotlin/com/titi/app/doamin/daily/usecase/GetResetDailyEventUseCase.kt b/domain/daily/src/main/kotlin/com/titi/app/doamin/daily/usecase/GetResetDailyEventUseCase.kt index d67888dd..63fd00ec 100644 --- a/domain/daily/src/main/kotlin/com/titi/app/doamin/daily/usecase/GetResetDailyEventUseCase.kt +++ b/domain/daily/src/main/kotlin/com/titi/app/doamin/daily/usecase/GetResetDailyEventUseCase.kt @@ -8,19 +8,23 @@ class GetResetDailyEventUseCase @Inject constructor( private val dailyRepository: DailyRepository, ) { suspend operator fun invoke(): Boolean { - val resetDaily = dailyRepository.getResetDailyEvent() - val today = getDailyDayWithHour(6).first + val resetEventDate = dailyRepository.getResetDailyEvent() + val (todayDate, endOfToday) = getDailyDayWithHour(6) - return if (resetDaily != null) { - if (resetDaily != today) { - dailyRepository.setResetDailyEvent(today) + return if (resetEventDate != null) { + if (resetEventDate != todayDate) { + dailyRepository.setResetDailyEvent(todayDate) true } else { false } } else { - dailyRepository.setResetDailyEvent(today) - true + dailyRepository.setResetDailyEvent(todayDate) + val dailyEvent = dailyRepository.getDateDaily( + startDateTime = todayDate, + endDateTime = endOfToday, + ) + dailyEvent == null } } }