mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-07-27 06:12:22 +02:00
BugFix Crashing relay screen on invalid URLs
This commit is contained in:
@@ -292,6 +292,7 @@ fun loadRelayInfo(
|
|||||||
scope: CoroutineScope,
|
scope: CoroutineScope,
|
||||||
onInfo: (RelayInformation) -> Unit
|
onInfo: (RelayInformation) -> Unit
|
||||||
) {
|
) {
|
||||||
|
try {
|
||||||
val url = if (dirtyUrl.contains("://")) {
|
val url = if (dirtyUrl.contains("://")) {
|
||||||
dirtyUrl
|
dirtyUrl
|
||||||
.replace("wss://", "https://")
|
.replace("wss://", "https://")
|
||||||
@@ -328,7 +329,7 @@ fun loadRelayInfo(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("RelayInfoFail", "Resulting Message from Relay in not parseable: $body", e)
|
Log.e("RelayInfoFail", "Resulting Message from Relay $dirtyUrl in not parseable: $body", e)
|
||||||
scope.launch {
|
scope.launch {
|
||||||
Toast
|
Toast
|
||||||
.makeText(
|
.makeText(
|
||||||
@@ -342,7 +343,7 @@ fun loadRelayInfo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailure(call: Call, e: IOException) {
|
override fun onFailure(call: Call, e: IOException) {
|
||||||
Log.e("RelayInfoFail", "Resulting Message from Relay in not parseable", e)
|
Log.e("RelayInfoFail", "Resulting Message from Relay in not parseable $dirtyUrl", e)
|
||||||
scope.launch {
|
scope.launch {
|
||||||
Toast
|
Toast
|
||||||
.makeText(
|
.makeText(
|
||||||
@@ -354,4 +355,15 @@ fun loadRelayInfo(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("RelayInfoFail", "Invalid URL $dirtyUrl", e)
|
||||||
|
scope.launch {
|
||||||
|
Toast
|
||||||
|
.makeText(
|
||||||
|
context,
|
||||||
|
context.getString(R.string.an_error_ocurred_trying_to_get_relay_information, dirtyUrl),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user