Fix some login issues (#23)

Fixes #21

Might also address #18

Fixes an issue with logging using username/password due to network
access on wrong thread exceptions.

Also adds better handling when deleting users or servers, especially if
it's the current one.
This commit is contained in:
damontecres 2025-10-17 12:05:40 -04:00 committed by GitHub
parent 0e195c18d7
commit bd4d4d5092
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 72 additions and 35 deletions

View file

@ -11,6 +11,7 @@ import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.key
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
@ -118,31 +119,33 @@ class MainActivity : AppCompatActivity() {
)
}
} else {
val initialDestination =
if (server != null && user != null) {
Destination.Home()
} else {
Destination.ServerList
}
val backStack = rememberNavBackStack(initialDestination)
navigationManager.backStack = backStack
if (appPreferences.autoCheckForUpdates) {
LaunchedEffect(Unit) {
try {
updateChecker.maybeShowUpdateToast(appPreferences.updateUrl)
} catch (ex: Exception) {
Timber.w(ex, "Failed to check for update")
key(server, user) {
val initialDestination =
if (server != null && user != null) {
Destination.Home()
} else {
Destination.ServerList
}
val backStack = rememberNavBackStack(initialDestination)
navigationManager.backStack = backStack
if (appPreferences.autoCheckForUpdates) {
LaunchedEffect(Unit) {
try {
updateChecker.maybeShowUpdateToast(appPreferences.updateUrl)
} catch (ex: Exception) {
Timber.w(ex, "Failed to check for update")
}
}
}
ApplicationContent(
user = user,
server = server,
navigationManager = navigationManager,
preferences = preferences,
deviceProfile = deviceProfile,
modifier = Modifier.fillMaxSize(),
)
}
ApplicationContent(
user = user,
server = server,
navigationManager = navigationManager,
preferences = preferences,
deviceProfile = deviceProfile,
modifier = Modifier.fillMaxSize(),
)
}
}
}