From 590c79c757408a31adf9c65eb7c413f4b7bc3cf3 Mon Sep 17 00:00:00 2001 From: Maxr1998 Date: Thu, 19 Nov 2020 18:33:44 +0100 Subject: [PATCH] Only change server location when different Prevents possible race conditions/crashes when using Android Auto simultaneously to the web client, caused by the server location change invalidating login credentials. --- .../main/java/org/jellyfin/mobile/viewmodel/MainViewModel.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/jellyfin/mobile/viewmodel/MainViewModel.kt b/app/src/main/java/org/jellyfin/mobile/viewmodel/MainViewModel.kt index 6e85c7e9..5fa56438 100644 --- a/app/src/main/java/org/jellyfin/mobile/viewmodel/MainViewModel.kt +++ b/app/src/main/java/org/jellyfin/mobile/viewmodel/MainViewModel.kt @@ -22,7 +22,9 @@ class MainViewModel( init { viewModelScope.launch { serverState.collect { state -> - apiClient.ChangeServerLocation(state.server?.hostname?.trimEnd('/')) + val serverAddress = state.server?.hostname?.trimEnd('/') + if (apiClient.serverAddress != serverAddress) + apiClient.ChangeServerLocation(serverAddress) } }