mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 16:11:20 +02:00
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:
parent
0e195c18d7
commit
bd4d4d5092
4 changed files with 72 additions and 35 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue