Fix crash when starting app from next up (#730)

## Description
Fixes a possible crash starting the app from the next up row

### Related issues
Fixes #729
This commit is contained in:
Ray 2026-01-20 13:49:46 -05:00 committed by GitHub
parent 7a20fedef4
commit 81d7aad0c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View file

@ -150,7 +150,6 @@ class MainActivity : AppCompatActivity() {
} }
} }
viewModel.appStart() viewModel.appStart()
val requestedDestination = this.intent?.let(::extractDestination)
setContent { setContent {
val appPreferences by userPreferencesDataStore.data.collectAsState(null) val appPreferences by userPreferencesDataStore.data.collectAsState(null)
appPreferences?.let { appPreferences -> appPreferences?.let { appPreferences ->
@ -257,6 +256,10 @@ class MainActivity : AppCompatActivity() {
} }
if (showContent) { if (showContent) {
val requestedDestination =
remember(intent) {
intent?.let(::extractDestination)
}
ApplicationContent( ApplicationContent(
user = current.user, user = current.user,
server = current.server, server = current.server,
@ -344,6 +347,7 @@ class MainActivity : AppCompatActivity() {
override fun onNewIntent(intent: Intent) { override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent) super.onNewIntent(intent)
Timber.v("onNewIntent") Timber.v("onNewIntent")
setIntent(intent)
extractDestination(intent)?.let { extractDestination(intent)?.let {
navigationManager.replace(it) navigationManager.replace(it)
} }

View file

@ -75,7 +75,11 @@ class NavigationManager
while (backStack.size > 1) { while (backStack.size > 1) {
backStack.removeLastOrNull() backStack.removeLastOrNull()
} }
backStack[0] = destination if (backStack.isEmpty()) {
backStack.add(0, destination)
} else {
backStack[0] = destination
}
log() log()
} }