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

@ -57,6 +57,7 @@ class ServerRepository
apiClient.update(baseUrl = server.url, accessToken = null)
_currentServer = server
_currentUser = null
_currentUserDto = null
}
/**
@ -160,6 +161,7 @@ class ServerRepository
suspend fun removeUser(user: JellyfinUser) {
if (currentUser == user) {
_currentUser = null
_currentUserDto = null
userPreferencesDataStore.updateData {
it
.toBuilder()
@ -177,13 +179,17 @@ class ServerRepository
suspend fun removeServer(server: JellyfinServer) {
if (currentServer == server) {
_currentServer = null
_currentUser = null
_currentUserDto = null
userPreferencesDataStore.updateData {
it
.toBuilder()
.apply {
currentServerId = ""
currentUserId = ""
}.build()
}
apiClient.update(baseUrl = null, accessToken = null)
}
withContext(Dispatchers.IO) {
serverDao.deleteServer(server.id)