From bc6ad2c771a6479ffdd48bc741febcfbb349c5dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=95=B4=EC=8B=9C?= <67777523+EmilyCh0@users.noreply.github.com> Date: Wed, 4 Oct 2023 10:34:41 +0900 Subject: [PATCH] =?UTF-8?q?[AN/USER]=20refactor:=20=ED=95=99=EA=B5=90=20?= =?UTF-8?q?=EC=84=A0=ED=83=9D=20=ED=99=94=EB=A9=B4=20success=20=EC=BA=90?= =?UTF-8?q?=EC=8A=A4=ED=8C=85=20=EC=BD=94=EB=93=9C=20=EB=A6=AC=ED=8C=A9(#4?= =?UTF-8?q?73)=20#475?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/selectschool/SelectSchoolViewModel.kt | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/selectschool/SelectSchoolViewModel.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/selectschool/SelectSchoolViewModel.kt index e49b07764..5a7bd892e 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/selectschool/SelectSchoolViewModel.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/selectschool/SelectSchoolViewModel.kt @@ -31,9 +31,9 @@ class SelectSchoolViewModel @Inject constructor( viewModelScope.launch { schoolRepository.loadSchools() .onSuccess { schools -> - if (uiState.value is SelectSchoolUiState.Success) { - val successState = (uiState.value as SelectSchoolUiState.Success) - _uiState.value = successState.copy(schools = schools) + val state = uiState.value + if (state is SelectSchoolUiState.Success) { + _uiState.value = state.copy(schools = schools) } else { _uiState.value = SelectSchoolUiState.Success(schools) } @@ -46,20 +46,18 @@ class SelectSchoolViewModel @Inject constructor( } fun selectSchool(schoolId: Long) { - if (uiState.value is SelectSchoolUiState.Success) { - _uiState.value = - (uiState.value as SelectSchoolUiState.Success).copy(selectedSchoolId = schoolId) + val state = uiState.value + if (state is SelectSchoolUiState.Success) { + _uiState.value = state.copy(selectedSchoolId = schoolId) } } fun showStudentVerification() { viewModelScope.launch { - if (uiState.value is SelectSchoolUiState.Success) { - val success = uiState.value as SelectSchoolUiState.Success - success.selectedSchoolId?.let { schoolId -> - _event.emit( - SelectSchoolEvent.ShowStudentVerification(schoolId) - ) + val state = uiState.value + if (state is SelectSchoolUiState.Success) { + state.selectedSchoolId?.let { schoolId -> + _event.emit(SelectSchoolEvent.ShowStudentVerification(schoolId)) } } }