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

Commit

Permalink
Check connection with server when adding custom server
Browse files Browse the repository at this point in the history
  • Loading branch information
M3DZIK committed May 25, 2024
1 parent 1d82d12 commit 585e9cc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import androidx.navigation.NavController
import dev.medzik.android.components.LoadingButton
import dev.medzik.android.components.rememberMutableBoolean
import dev.medzik.android.components.rememberMutableString
import dev.medzik.android.utils.showToast
import dev.medzik.librepass.android.R
import dev.medzik.librepass.android.ui.components.TextInputField
import dev.medzik.librepass.android.utils.SecretStore.readKey
import dev.medzik.librepass.android.utils.SecretStore.writeKey
import dev.medzik.librepass.android.utils.StoreKey
import dev.medzik.librepass.client.api.checkApiConnection

@Composable
fun AddCustomServerScreen(navController: NavController) {
Expand All @@ -30,7 +32,10 @@ fun AddCustomServerScreen(navController: NavController) {
fun submit(server: String) {
loading = true

// TODO: ping server to check connection
if (!checkApiConnection(server)) {
context.showToast(R.string.Tost_NoServerConnection)
return
}

val servers = context.readKey(StoreKey.CustomServers)
context.writeKey(StoreKey.CustomServers, servers.plus(server))
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
<string name="Toast_Enter_Email">Wprowadź swój adres e-mail</string>
<string name="Toast_Password_Hint_Sent">Podpowiedź dotycząca hasła została wysłana na adres e-mail</string>
<string name="Toast_PleaseVerifyYourEmail">Zweryfikuj swój adres e-mail</string>
<string name="Tost_NoServerConnection">Brak połączenia z serwerem</string>
<string name="Unlock">Odblokuj</string>
<string name="UnlockWithBiometrics">Odblokowanie za pomocą danych biometrycznych</string>
<string name="UseBiometric">Użyj biometrii</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
<string name="Toast_Enter_Email">Enter your e-mail address</string>
<string name="Toast_Password_Hint_Sent">A password hint was sent to the email address</string>
<string name="Toast_PleaseVerifyYourEmail">Please verify your e-mail address</string>
<string name="Tost_NoServerConnection">No connection with the server</string>
<string name="Unlock">Unlock</string>
<string name="UnlockWithBiometrics">Unlock with biometrics</string>
<string name="UseBiometric">Use biometric</string>
Expand Down

0 comments on commit 585e9cc

Please sign in to comment.