Skip to content

Commit

Permalink
[FEATURE]#223 : 로그아웃 시, 로그아웃 API 호출 성공한 경우에만 처리하도록 수정 + 회원탈퇴 API 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongjaino committed Jan 26, 2025
1 parent 37801b6 commit 01309b7
Showing 1 changed file with 36 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class EntireViewModel @Inject constructor(
EntireAction.OnRevokeScreenEntered -> observeProfileDataFlow()
EntireAction.OnBlockListScreenEntered -> getBlockedMessageList()
EntireAction.OnRevokeConfirmed -> handleRevokeConfirmed()
EntireAction.OnRevokeButtonClicked -> revokeUser()
EntireAction.OnSignOutButtonClicked -> signOut()
EntireAction.OnRevokeButtonClicked -> handleRevoke()
EntireAction.OnSignOutButtonClicked -> handleSignOut()
EntireAction.UnBlockMessage -> unblockMessage()
EntireAction.OnInputRevokeReasonSelected -> handleInputRevokeReasonSelected()
is EntireAction.OnUnBlockButtonClicked -> handleUnBlockButtonClicked(action.messageId)
Expand Down Expand Up @@ -93,34 +93,49 @@ class EntireViewModel @Inject constructor(
reduce { state.copy(webLinkMap = webLinkMap) }
}

private fun revokeUser() = intent {
private fun handleRevoke() = intent {
reduce { state.copy(isLoading = true) }
val revokeReason = if (state.isInputRevokeReasonSelected) {
state.revokeReasonList + state.inputRevokeReason
} else {
state.revokeReasonList
}

viewModelScope.launch {
launch {
authRepository.revoke(revokeReason)
.onSuccess {
clearCachedData()
postSideEffect(EntireSideEffect.NavigateToAuth)
}
.onNetworkFailure {
postSideEffect(it.toSideEffect())
}
.onFailure {
Timber.e(it)
}
}
viewModelScope.launch(coroutineDispatcher) {
authRepository.revoke(revokeReason)
.onSuccess {
KakaoLoginManager.revoke()
clearCachedData()
postSideEffect(EntireSideEffect.NavigateToAuth)
}
.onNetworkFailure {
postSideEffect(it.toSideEffect())
}
.onFailure {
reduce { state.copy(isLoading = false) }
Timber.e(it)
}
}
}

private fun signOut() = intent {
clearCachedData()
KakaoLoginManager.logout()
postSideEffect(EntireSideEffect.NavigateToAuth)
private fun handleSignOut() = intent {
reduce { state.copy(isLoading = true) }

viewModelScope.launch(coroutineDispatcher) {
authRepository.signOut()
.onSuccess {
KakaoLoginManager.logout()
clearCachedData()
postSideEffect(EntireSideEffect.NavigateToAuth)
}
.onNetworkFailure {
postSideEffect(it.toSideEffect())
}
.onFailure {
reduce { state.copy(isLoading = false) }
Timber.e(it)
}
}
}

private fun clearCachedData() {
Expand Down

0 comments on commit 01309b7

Please sign in to comment.