Skip to content

Commit

Permalink
Merge pull request #186 from wespot-bff/feature/flash159483/#181
Browse files Browse the repository at this point in the history
#181: 카카오톡 로그인 뒤로갈시 튕기는 버그 수정
  • Loading branch information
flash159483 authored Oct 11, 2024
2 parents 424e776 + fd4f120 commit 3541d49
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class KakaoLoginManager {
private suspend fun UserApiClient.Companion.loginWithKakaoTalk(context: Context): OAuthToken {
return suspendCancellableCoroutine { continuation ->
instance.loginWithKakaoTalk(context) { token, error ->
Timber.d("loginWithKakaoTalk token: $token, error: $error")
continuation.resumeTokenOrException(token, error)
}
}
Expand Down Expand Up @@ -82,6 +81,16 @@ class KakaoLoginManager {
resumeWithException(RuntimeException("Failed to get kakao access token, reason is not clear."))
}
}

companion object {
fun logout() = UserApiClient.instance.logout { error ->
if (error != null) {
Timber.d("로그아웃 실패. SDK에서 토큰 삭제됨")
} else {
Timber.d("로그아웃 성공. SDK에서 토큰 삭제됨")
}
}
}
}

enum class KaKaoLoginState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ fun AuthScreen(
Button(
onClick = {
coroutineScope.launch {
val token = kakaoLogin.loginWithKakao(context)
viewModel.onAction(AuthAction.LoginWithKakao(token))
runCatching {
val token = kakaoLogin.loginWithKakao(context)
viewModel.onAction(AuthAction.LoginWithKakao(token))
}
}
},
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.bff.wespot.model.common.Paging
import com.bff.wespot.model.message.response.BlockedMessage
import com.bff.wespot.ui.base.BaseViewModel
import com.bff.wespot.ui.model.SideEffect.Companion.toSideEffect
import com.bff.wespot.ui.util.KakaoLoginManager
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.distinctUntilChanged
Expand Down Expand Up @@ -110,6 +111,7 @@ class EntireViewModel @Inject constructor(

private fun signOut() = intent {
clearCachedData()
KakaoLoginManager.logout()
postSideEffect(EntireSideEffect.NavigateToAuth)
}

Expand Down

0 comments on commit 3541d49

Please sign in to comment.