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

feat: 열람실 이용을 시작할 때 uiState의 오늘 studyCount를 늘리는 로직을 구현 #146

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

librarywon
Copy link
Contributor

resolved #145

AS-IS

  • 기존에는 열람실 이용 종료를 해야 오늘 날짜 별의 색상이 변경되었습니다

TO-BE

  • 열람실 이용 시작과 동시에 오늘 날짜 별의 색상이 변경되도록 수정합니다.

KEY-POINT

  • update 보단 1증가 시킨다는 표현을 위해 함수 이름에 increment를 사용하였습니다.

SCREENSHOT (Optional)

Screen_recording_20241126_162413.mp4

@librarywon librarywon self-assigned this Nov 26, 2024
Copy link
Contributor

@no1msh no1msh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!

@@ -107,6 +107,7 @@ fun HomeRoute(
updateSelectedTime(updatedSelectedTime)
updateTimePickerVisibility(false)
updateTimerRunning(true)
incrementTodayStudyCount()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

increment는 명사라
increase를 메소드 시작 이름으로 추천드립니다.

Copy link
Contributor Author

@librarywon librarywon Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

저도 이름이 고민이였어서 GPT 검색을 했었는데요 이렇게도 사용 가능하다고 합니다!

Comment on lines +121 to +142
fun incrementTodayStudyCount() {
_homeUiState.update { currentState ->
when (currentState) {
is HomeUiState.Success -> {
val updatedWeeklyStudyDays: List<WeeklyStudyDay> =
currentState.weeklyStudyDays.map { studyDay ->
if (studyDay.date ==
LocalDate.now()
.format(DateTimeFormatter.ofPattern("M/dd"))
) {
studyDay.copy(studyCount = studyDay.studyCount + 1)
} else {
studyDay
}
}
currentState.copy(weeklyStudyDays = updatedWeeklyStudyDays)
}

else -> currentState
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

실제 서버엔 적용 안되는 낙관적 UI로 구현하신건가요?
추후 열람실 이용이 종료되면 그제서야 서버에 요청이 들어가는 구조인가요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 맞습니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] 열람실 이용 시작시 별의 색상을 바로 변경하는 로직 추가
2 participants