Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
Fix crashing when provided invalid custom server address
Browse files Browse the repository at this point in the history
  • Loading branch information
M3DZIK committed May 25, 2024
1 parent 6c68b1d commit bd6a44d
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import com.google.gson.JsonSyntaxException
import dev.medzik.android.components.LoadingButton
import dev.medzik.android.components.rememberMutableBoolean
import dev.medzik.android.components.rememberMutableString
Expand All @@ -35,7 +36,16 @@ fun AddCustomServerScreen(navController: NavController) {
loading = true

runOnIOThread {
if (!checkApiConnection(server)) {
// TODO: Delete try when released new version of LibrePass client library
try {
if (!checkApiConnection(server)) {
context.showToast(R.string.Tost_NoServerConnection)

loading = false

return@runOnIOThread
}
} catch (e: JsonSyntaxException) {
context.showToast(R.string.Tost_NoServerConnection)

loading = false
Expand Down

0 comments on commit bd6a44d

Please sign in to comment.