diff --git a/app/src/main/java/org/sopt/and/presentation/ui/auth/screen/AuthViewModel.kt b/app/src/main/java/org/sopt/and/presentation/ui/auth/screen/AuthViewModel.kt index 773afbd..dd592fb 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/auth/screen/AuthViewModel.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/auth/screen/AuthViewModel.kt @@ -27,13 +27,12 @@ class AuthViewModel @Inject constructor( val signUpState: StateFlow = _signUpState fun validateSignIn(username: String, password: String) { - _signInState.value = SignInState.Loading viewModelScope.launch { + _signInState.value = SignInState.Loading val result = authRepository.login(username = username, password = password) _signInState.value = result.fold( onSuccess = { token -> tokenRepository.setToken(token.token) - Log.d("token", "토큰 저장 완료! 저장값은 ${token.token} 입니다.") SignInState.Success(token) }, onFailure = { @@ -44,8 +43,8 @@ class AuthViewModel @Inject constructor( } fun validateSignUp(username: String, password: String, hobby: String) { - _signUpState.value = SignUpState.Loading viewModelScope.launch { + _signUpState.value = SignUpState.Loading val result = authRepository.registerUser( user = User( username = username, diff --git a/app/src/main/java/org/sopt/and/presentation/ui/main/screen/MainViewModel.kt b/app/src/main/java/org/sopt/and/presentation/ui/main/screen/MainViewModel.kt index 77c6148..8f2cf10 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/main/screen/MainViewModel.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/main/screen/MainViewModel.kt @@ -23,12 +23,13 @@ class MainViewModel @Inject constructor( private val _hobbySearchState = MutableStateFlow(HobbySearchState.Idle) val hobbySearchState: StateFlow = _hobbySearchState - private val _userInfoUpdateState = MutableStateFlow(UserInfoUpdateState.Idle) + private val _userInfoUpdateState = + MutableStateFlow(UserInfoUpdateState.Idle) val userInfoUpdateState: StateFlow = _userInfoUpdateState fun getUserHobby() { - _userHobbyState.value = UserHobbyState.Loading viewModelScope.launch { + _userHobbyState.value = UserHobbyState.Loading val result = userRepository.getMyHobby(token = token) _userHobbyState.value = result.fold( onSuccess = { @@ -42,8 +43,8 @@ class MainViewModel @Inject constructor( } fun getOthersHobby(userNo: String) { - _hobbySearchState.value = HobbySearchState.Loading viewModelScope.launch { + _hobbySearchState.value = HobbySearchState.Loading val result = userRepository.getOthersHobby( token = token, userNo = userNo.toInt() @@ -60,8 +61,8 @@ class MainViewModel @Inject constructor( } fun updateUserInfo(password: String?, hobby: String?) { - _userInfoUpdateState.value = UserInfoUpdateState.Loading viewModelScope.launch { + _userInfoUpdateState.value = UserInfoUpdateState.Loading val result = userRepository.updateUserInfo( token = token, password = password,