Colton Idle
03/07/2024, 6:08 AMLaunchedEffect(navigator) {
val bundle = webViewState.viewState
if (bundle == null) {
// This is the first time load, so load the home page.
navigator.loadUrl("<https://bbc.com>")
}
}
Easy! But now I need to add an auth header. Okay not bad
navigator.loadUrl("<https://bbc.com>", "AUTH" to $token)
but now my issue is that when the token is updated, it doesn't cause a reload. How would you solve this?Colton Idle
03/07/2024, 6:10 AMLaunchedEffect(navigator) {
val bundle = webViewState.viewState
if (bundle == null) {
// This is the first time load, so load the home page.
navigator.loadUrl("<https://bbc.com>", "AUTH" to $token)
}
}
but not sure how to best update this. If I try to add a key of token to the launchedEffect it of course doesn't get called because the bundle isn't null.
It's almost as if it'd be helpful if I could look into the current webview and see if there is already a header applied, but it doesn't seem possible to get request headers from a webview instance.MR3Y
03/07/2024, 7:40 PMvar isFirstTime by rememberSaveable(webViewState) { mutableStateOf(true) }
....
// Inside bundle == null check
isFirstTime = false
// Add separate LaunchedEffect block keyed with token
LaunchedEffect(token) {
if(!isFirstTime) {
navigator.loadUrl(url, token)
}
}
More or less something like this. I'm on mobile so code formatting might look weird :).Colton Idle
03/07/2024, 8:08 PMzt
03/11/2024, 1:26 AMColton Idle
03/11/2024, 3:20 AM