Skip to content

Commit 652af71

Browse files
authored
Merge pull request #141 from parkdu7/feat/android/bottomsheet
fix: AppNav 로그인 상태에 따른 라우팅 로직 수정
2 parents 39674d7 + c278413 commit 652af71

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

  • android/campung/app/src/main/java/com/shinhan/campung/navigation

android/campung/app/src/main/java/com/shinhan/campung/navigation/AppNav.kt

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,20 @@ fun AppNav(
5555
onNavControllerReady(navController)
5656
}
5757

58-
// 1) 상태 수집: 로그인 상태
58+
// 1) 로딩 상태 관리
59+
var isInitialLoading by remember { mutableStateOf(true) }
5960
val userId by authDataStore.userIdFlow.collectAsState(initial = null)
60-
61-
// 2) userId가 아직 로드되지 않았으면 로딩 화면 표시
62-
if (userId == null) {
61+
62+
// 2) 첫 번째 값이 도착하면 (null이든 실제값이든) 로딩 완료
63+
LaunchedEffect(Unit) {
64+
val firstValue = authDataStore.userIdFlow.first()
65+
isInitialLoading = false
66+
android.util.Log.d("AppNav", "DataStore 로딩 완료 - userId: '$firstValue'")
67+
}
68+
69+
// 3) 초기 로딩 중이면 로딩 화면 표시
70+
if (isInitialLoading) {
71+
android.util.Log.d("AppNav", "초기 로딩 중...")
6372
Box(
6473
modifier = Modifier.fillMaxSize(),
6574
contentAlignment = Alignment.Center
@@ -69,8 +78,13 @@ fun AppNav(
6978
return
7079
}
7180

72-
// 3) userId가 로드된 후 적절한 화면 결정
73-
val startRoute = if (userId?.isBlank() != false) Route.LOGIN else Route.HOME
81+
// 4) 로딩 완료 후 적절한 화면 결정
82+
val startRoute = if (userId.isNullOrBlank()) Route.LOGIN else Route.HOME
83+
84+
// 디버깅 로그
85+
LaunchedEffect(startRoute) {
86+
android.util.Log.d("AppNav", "라우팅 결정: userId = '$userId', startRoute = '$startRoute'")
87+
}
7488

7589
Box(modifier = Modifier.fillMaxSize()) {
7690
// 항상 깔리는 기본 배경 (검은 잔상 방지)

0 commit comments

Comments
 (0)