Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#184 : 타이머 시작시, 쪽지 상태 불러오는 코드 추가해요 #185

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading