Skip to content

Commit

Permalink
Merge pull request #185 from wespot-bff/feature/jaino/#184
Browse files Browse the repository at this point in the history
#184 : 타이머 시작시, 쪽지 상태 불러오는 코드 추가해요
  • Loading branch information
jeongjaino authored Oct 9, 2024
2 parents ef41174 + 8360e15 commit 424e776
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class MessageViewModel @Inject constructor(

private fun startTimer() = intent {
if (!timerJob.isActive) {
setTimer()
timerJob.start()
}
}
Expand Down Expand Up @@ -130,22 +131,20 @@ class MessageViewModel @Inject constructor(
}
}

/**
* TimePeriod Default 값은 DAWN_TO_EVENING으로
* DAWN_TO_EVENING 상태에서 다른 행동을 수행하지 않기 때문에, TimePeriod가 변경되었을 때만 행동을 수행한다.
*/
private fun updateTimePeriod(currentTimePeriod: TimePeriod) = intent {
if (state.timePeriod != currentTimePeriod) {
getMessageStatus()

// 메세지 전송 가능한 시간이 경우, 타이머 시각을 설정한다.
if (currentTimePeriod == TimePeriod.EVENING_TO_NIGHT) {
_remainingTimeMillis.value = getRemainingTimeMillis()
}

reduce {
state.copy(timePeriod = currentTimePeriod)
}
setTimer()
}
}

private fun setTimer() = intent {
getMessageStatus()

if (state.timePeriod == TimePeriod.EVENING_TO_NIGHT) {
_remainingTimeMillis.value = getRemainingTimeMillis()
}
}

Expand Down

0 comments on commit 424e776

Please sign in to comment.