[Fix] 카카오 뒤로가기 이슈 해결#133
Conversation
📝 WalkthroughWalkthrough로그인 흐름이 상태 기반(VerifyStatusData)에서 이벤트 기반(LoginNavigationEvent) 네비게이션으로 리팩토링되었습니다. LoginViewModel은 SharedFlow로 네비게이션 이벤트를 발행하고 LoginScreen은 이를 수집해 Home 또는 OnBoarding으로 이동합니다. Changes
Sequence Diagram(s)sequenceDiagram
participant UI as "LoginScreen (UI)"
participant VM as "LoginViewModel"
participant Repo as "AuthRepository"
participant Nav as "Navigator"
rect rgba(135,206,235,0.5)
UI->>VM: Kakao 로그인 요청 (socialVerifyWithKakao)
VM->>Repo: socialVerify request
Repo-->>VM: response (success: isRegistered?/tempToken)
end
rect rgba(144,238,144,0.5)
VM-->>UI: emit UiState.Success(NavigateToHome) or UiState.Success(NavigateToOnBoarding(tempToken))
UI->>Nav: Dispatch navigation action (Home or OnBoarding with token)
Nav-->>UI: Navigate completed
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
개요로그인 흐름이 상태 기반 검증에서 이벤트 기반 네비게이션으로 리팩토링되었습니다. LoginViewModel이 PreferencesManager를 제거하고 SharedFlow를 통해 LoginNavigationEvent를 발행하며, LoginScreen이 이벤트를 구독하여 네비게이션을 처리하는 구조로 변경되었습니다. 변경사항
예상 코드 리뷰 시간🎯 3 (보통) | ⏱️ ~20분 관련 가능 PR
추천 리뷰어
시
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (1 warning, 2 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@app/src/main/java/com/flint/presentation/login/LoginViewModel.kt`:
- Line 30: Check for null/empty tempToken before emitting NavigateToOnBoarding:
in the LoginViewModel where you call
_navigationEvent.emit(UiState.Success(LoginNavigationEvent.NavigateToOnBoarding(data.tempToken
?: ""))), validate data.tempToken (reference: data.tempToken) and if it is null
or blank emit an error state (e.g., UiState.Error or a dedicated
LoginNavigationEvent.ShowError) instead of substituting an empty string, so the
onboarding/signup flow never receives an invalid empty token.
🧹 Nitpick comments (2)
app/src/main/java/com/flint/presentation/login/LoginScreen.kt (1)
44-60: SharedFlow를 사용한 네비게이션 이벤트 수집 패턴이 적절합니다.
LaunchedEffect(Unit)와collect를 사용하여 일회성 네비게이션 이벤트를 처리하는 것은 카카오 뒤로가기 이슈를 해결하기 위한 올바른 접근 방식입니다. SharedFlow는 replay가 없어 중복 네비게이션을 방지합니다.다만,
UiState.Failure케이스가 무시되고 있어 로그인 실패 시 사용자에게 피드백이 전달되지 않습니다. 에러 핸들링 추가를 고려해 주세요.💡 에러 핸들링 추가 제안
when (uiState) { is UiState.Success -> { when(val event = uiState.data) { is LoginNavigationEvent.NavigateToHome -> { navigateToHome() } is LoginNavigationEvent.NavigateToOnBoarding -> { navigateToOnBoarding(event.tempToken) } } } - else -> {} + is UiState.Failure -> { + // TODO: 로그인 실패 시 사용자에게 에러 메시지 표시 + Timber.e("Login failed") + } + is UiState.Loading -> { /* 로딩 상태 처리 */ } }app/src/main/java/com/flint/presentation/login/LoginViewModel.kt (1)
19-20: SharedFlow 버퍼 설정 확인 필요
MutableSharedFlow의 기본 파라미터(replay=0, extraBufferCapacity=0)를 사용하면, collector가 준비되지 않은 상태에서emit이 호출될 경우 suspend될 수 있습니다. 네비게이션 이벤트가 유실되지 않도록extraBufferCapacity를 추가하는 것을 권장합니다.💡 버퍼 용량 추가 제안
- private val _navigationEvent = MutableSharedFlow<UiState<LoginNavigationEvent>>() + private val _navigationEvent = MutableSharedFlow<UiState<LoginNavigationEvent>>(extraBufferCapacity = 1)
| if (data.isRegistered) { | ||
| _navigationEvent.emit(UiState.Success(LoginNavigationEvent.NavigateToHome)) | ||
| } else { | ||
| _navigationEvent.emit(UiState.Success(LoginNavigationEvent.NavigateToOnBoarding(data.tempToken ?: ""))) |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
rg -n "tempToken" --type kotlin -C 3Repository: imflint/Flint-Android
Length of output: 10092
🏁 Script executed:
rg -n "tempToken" --type kotlin app/src/main/java/com/flint/presentation/onboarding/ -C 5Repository: imflint/Flint-Android
Length of output: 1585
🏁 Script executed:
fd "OnboardingProfileRoute" --type f --extension ktRepository: imflint/Flint-Android
Length of output: 47
🏁 Script executed:
rg "fun OnboardingProfileRoute|@Composable.*OnboardingProfileRoute" --type kotlin -A 20Repository: imflint/Flint-Android
Length of output: 2243
🏁 Script executed:
rg "composable<Route.OnboardingProfile>" --type kotlin -A 15Repository: imflint/Flint-Android
Length of output: 1980
🏁 Script executed:
rg "savedStateHandle|navBackStackEntry" --type kotlin app/src/main/java/com/flint/presentation/onboarding/ -B 2 -A 5 | head -100Repository: imflint/Flint-Android
Length of output: 47
🏁 Script executed:
fd "OnboardingViewModel\|OnboardingProfileViewModel" --type f --extension ktRepository: imflint/Flint-Android
Length of output: 47
🏁 Script executed:
rg "tempToken" --type kotlin app/src/main/java/com/flint/presentation/onboarding/ -B 3 -A 3Repository: imflint/Flint-Android
Length of output: 1044
🏁 Script executed:
rg "SignupRequestModel\|SignupRequestDto" --type kotlin -B 2 -A 8 | head -80Repository: imflint/Flint-Android
Length of output: 47
🏁 Script executed:
fd "Signup" --type f --extension kt | head -20Repository: imflint/Flint-Android
Length of output: 328
🏁 Script executed:
rg "SignupRequestModel" --type kotlin app/src/main/java/com/flint/presentation/ -B 2 -A 2Repository: imflint/Flint-Android
Length of output: 47
🏁 Script executed:
rg "SignupRequestModel" --type kotlin -B 2 -A 2Repository: imflint/Flint-Android
Length of output: 3583
빈 문자열로의 tempToken 변환 재검토 필요
data.tempToken이 null일 때 빈 문자열("")로 대체하면, 이후 온보딩 화면을 거쳐 회원가입 API 호출 시 빈 tempToken이 그대로 전송됩니다. 로그인 단계에서 tempToken의 존재 여부를 검증하고 null인 경우 적절한 에러 처리를 하는 것이 권장됩니다.
🤖 Prompt for AI Agents
In `@app/src/main/java/com/flint/presentation/login/LoginViewModel.kt` at line 30,
Check for null/empty tempToken before emitting NavigateToOnBoarding: in the
LoginViewModel where you call
_navigationEvent.emit(UiState.Success(LoginNavigationEvent.NavigateToOnBoarding(data.tempToken
?: ""))), validate data.tempToken (reference: data.tempToken) and if it is null
or blank emit an error state (e.g., UiState.Error or a dedicated
LoginNavigationEvent.ShowError) instead of substituting an empty string, so the
onboarding/signup flow never receives an invalid empty token.
| sealed interface LoginNavigationEvent { | ||
| data object NavigateToHome : LoginNavigationEvent | ||
| data class NavigateToOnBoarding(val tempToken: String) : LoginNavigationEvent | ||
| } No newline at end of file |
There was a problem hiding this comment.
p3
NavigationeEvent만 이런 식으로 관리하나요??
스낵바 표시나 에러 다이얼로그 같은 것도 SideEffect로 묶어서 관리해보면 혹시 어떨까 싶어서..!
There was a problem hiding this comment.
해당 화면에 navigation event밖에 없어서 저렇게 구성해두었습니다. 일단 수정 편의성을 높이기 위해 별도의 파일로 이동시키겠습니다
nahy-512
left a comment
There was a problem hiding this comment.
고생하셨습니다. 네비게이션 코드 SideEffect로 처리하니까 훨씬 마음이 편안하네요잉
📮 관련 이슈
📌 작업 내용
Summary by CodeRabbit
릴리스 노트
✏️ Tip: You can customize this high-level summary in your review settings.