diff --git a/core/data/src/main/kotlin/com/withpeace/withpeace/core/data/repository/DefaultUserRepository.kt b/core/data/src/main/kotlin/com/withpeace/withpeace/core/data/repository/DefaultUserRepository.kt index 36a02460..dee69fac 100644 --- a/core/data/src/main/kotlin/com/withpeace/withpeace/core/data/repository/DefaultUserRepository.kt +++ b/core/data/src/main/kotlin/com/withpeace/withpeace/core/data/repository/DefaultUserRepository.kt @@ -96,7 +96,7 @@ class DefaultUserRepository @Inject constructor( override fun verifyNicknameDuplicated( nickname: Nickname, - onError: (WithPeaceError) -> Unit, + onError: suspend (WithPeaceError) -> Unit, ): Flow = flow { userService.isNicknameDuplicate(nickname.value).suspendMapSuccess { if (this.data) { diff --git a/core/domain/src/main/java/com/withpeace/withpeace/core/domain/repository/UserRepository.kt b/core/domain/src/main/java/com/withpeace/withpeace/core/domain/repository/UserRepository.kt index f1fcea13..724992bf 100644 --- a/core/domain/src/main/java/com/withpeace/withpeace/core/domain/repository/UserRepository.kt +++ b/core/domain/src/main/java/com/withpeace/withpeace/core/domain/repository/UserRepository.kt @@ -1,7 +1,6 @@ package com.withpeace.withpeace.core.domain.repository import com.withpeace.withpeace.core.domain.model.WithPeaceError -import com.withpeace.withpeace.core.domain.model.profile.ChangingProfileInfo import com.withpeace.withpeace.core.domain.model.profile.Nickname import com.withpeace.withpeace.core.domain.model.profile.ProfileInfo import kotlinx.coroutines.flow.Flow @@ -15,21 +14,21 @@ interface UserRepository { fun updateProfileImage( profileImage: String, - onError: (WithPeaceError) -> Unit, + onError: suspend (WithPeaceError) -> Unit, ): Flow fun updateNickname( nickname: String, - onError: (WithPeaceError) -> Unit, + onError: suspend (WithPeaceError) -> Unit, ): Flow fun updateProfile( nickname: String, profileImage: String, - onError: (WithPeaceError) -> Unit, + onError: suspend (WithPeaceError) -> Unit, ): Flow fun verifyNicknameDuplicated( nickname: Nickname, - onError: (WithPeaceError) -> Unit, + onError: suspend (WithPeaceError) -> Unit, ): Flow } diff --git a/core/domain/src/main/java/com/withpeace/withpeace/core/domain/usecase/UpdateProfileUseCase.kt b/core/domain/src/main/java/com/withpeace/withpeace/core/domain/usecase/UpdateProfileUseCase.kt index 7cb0d1ef..8831bdcc 100644 --- a/core/domain/src/main/java/com/withpeace/withpeace/core/domain/usecase/UpdateProfileUseCase.kt +++ b/core/domain/src/main/java/com/withpeace/withpeace/core/domain/usecase/UpdateProfileUseCase.kt @@ -13,7 +13,7 @@ class UpdateProfileUseCase @Inject constructor( operator fun invoke( beforeProfile: ChangingProfileInfo, afterProfile: ChangingProfileInfo, - onError: (WithPeaceError) -> Unit, + onError: suspend (WithPeaceError) -> Unit, ): Flow { return when (ProfileChangingStatus.getStatus(beforeProfile, afterProfile)) { ProfileChangingStatus.AllChanging -> { diff --git a/core/domain/src/main/java/com/withpeace/withpeace/core/domain/usecase/VerifyNicknameUseCase.kt b/core/domain/src/main/java/com/withpeace/withpeace/core/domain/usecase/VerifyNicknameUseCase.kt index e4719dbc..d821b97d 100644 --- a/core/domain/src/main/java/com/withpeace/withpeace/core/domain/usecase/VerifyNicknameUseCase.kt +++ b/core/domain/src/main/java/com/withpeace/withpeace/core/domain/usecase/VerifyNicknameUseCase.kt @@ -10,10 +10,9 @@ import javax.inject.Inject class VerifyNicknameUseCase @Inject constructor( private val userRepository: UserRepository, ) { - operator fun invoke(nickname: String, onError: (WithPeaceError) -> Unit): Flow { + operator fun invoke(nickname: String, onError: suspend (WithPeaceError) -> Unit): Flow { if (!Nickname.verifyNickname(nickname)) { - onError(WithPeaceError.GeneralError(code = 1)) - return flow { } + return flow { onError(WithPeaceError.GeneralError(code = 1)) } } return userRepository.verifyNicknameDuplicated(Nickname.create(nickname), onError = onError) } diff --git a/feature/profileeditor/src/main/java/com/app/profileeditor/ProfileEditorViewModel.kt b/feature/profileeditor/src/main/java/com/app/profileeditor/ProfileEditorViewModel.kt index f8f04b72..f132854c 100644 --- a/feature/profileeditor/src/main/java/com/app/profileeditor/ProfileEditorViewModel.kt +++ b/feature/profileeditor/src/main/java/com/app/profileeditor/ProfileEditorViewModel.kt @@ -84,7 +84,6 @@ class ProfileEditorViewModel @Inject constructor( viewModelScope.launch { verifyNicknameUseCase( onError = { error -> - this.launch { _profileEditUiEvent.send( when (error) { is WithPeaceError.GeneralError -> { @@ -94,11 +93,9 @@ class ProfileEditorViewModel @Inject constructor( else -> ProfileEditUiEvent.ShowFailure } } - else -> ProfileEditUiEvent.ShowFailure }, ) - } }, nickname = (profileEditUiState.value as ProfileEditUiState.Editing).profileInfo.nickname, ).collect {