Skip to content

Commit 351362e

Browse files
committed
fix(nav): move AuthCheck inside Navigator root
prevent a possible race condition where AuthCheck fires _before_ MainRoot is set as root Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent 83260f5 commit 351362e

3 files changed

Lines changed: 17 additions & 17 deletions

File tree

app/src/main/java/com/getcode/CodeApp.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,23 +88,23 @@ fun CodeApp() {
8888
StackEvent.Replace -> CurrentScreen()
8989
}
9090
}
91-
}
92-
}
9391

94-
//Listen for authentication changes here
95-
AuthCheck(
96-
navigator = codeNavigator,
97-
onNavigate = { screens ->
98-
codeNavigator.replaceAll(screens, inSheet = false)
99-
},
100-
onSwitchAccounts = { seed ->
101-
activity?.let {
102-
tlvm.logout(it) {
103-
appState.navigator.replaceAll(LoginScreen(seed))
92+
//Listen for authentication changes here
93+
AuthCheck(
94+
navigator = codeNavigator,
95+
onNavigate = { screens ->
96+
codeNavigator.replaceAll(screens, inSheet = false)
97+
},
98+
onSwitchAccounts = { seed ->
99+
activity?.let {
100+
tlvm.logout(it) {
101+
appState.navigator.replaceAll(LoginScreen(seed))
102+
}
103+
}
104104
}
105-
}
105+
)
106106
}
107-
)
107+
}
108108
}
109109

110110
TopBarContainer(appState)

app/src/main/java/com/getcode/view/components/AuthCheck.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ fun AuthCheck(
9191
deeplinkHandler.intent
9292
.flatMapLatest { combine(flowOf(deeplinkHandler.handle(it)), SessionManager.authState) { a, b -> a to b } }
9393
.filter { (result, authState) ->
94-
startupLog("checking auth state=${authState.isAuthenticated}")
95-
// wait for authentication
9694
if (result == null) return@filter false
95+
// wait for authentication
96+
startupLog("checking auth state=${authState.isAuthenticated}")
9797
if( authState.isAuthenticated == null) {
9898
startupLog("awaiting auth state confirmation")
9999
return@filter false

app/src/main/java/com/getcode/view/main/home/HomeScan.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private fun HomeScan(
143143
val navigator = LocalCodeNavigator.current
144144
val scope = rememberCoroutineScope()
145145

146-
var isPaused by rememberSaveable { mutableStateOf(false) }
146+
var isPaused by remember { mutableStateOf(false) }
147147

148148
var kikCodeScannerView: KikCodeScannerView? by remember { mutableStateOf(null) }
149149

0 commit comments

Comments
 (0)