Alerts with network errors

This commit is contained in:
Avently
2022-10-14 13:32:24 +03:00
parent 34a9a81524
commit 3e3fa931ac
@@ -842,16 +842,10 @@ open class ChatController(var ctrl: ChatCtrl?, val ntfManager: NtfManager, val a
suspend fun apiCreateGroupLink(groupId: Long): String? {
return when (val r = sendCmd(CC.APICreateGroupLink(groupId))) {
is CR.GroupLinkCreated -> r.connReqContact
is CR.ChatCmdError -> {
AlertManager.shared.showAlertMsg(generalGetString(R.string.error_creating_link_for_group), "$r.chatError")
null
}
else -> {
Log.e(TAG, "apiCreateGroupLink bad response: ${r.responseType} ${r.details}")
AlertManager.shared.showAlertMsg(
generalGetString(R.string.error_creating_link_for_group),
"${r.responseType}: ${r.details}"
)
if (!(networkErrorAlert(r))) {
apiErrorAlert("apiCreateGroupLink", generalGetString(R.string.error_creating_link_for_group), r)
}
null
}
}
@@ -860,16 +854,10 @@ open class ChatController(var ctrl: ChatCtrl?, val ntfManager: NtfManager, val a
suspend fun apiDeleteGroupLink(groupId: Long): GroupInfo? {
return when (val r = sendCmd(CC.APIDeleteGroupLink(groupId))) {
is CR.GroupLinkDeleted -> r.groupInfo
is CR.ChatCmdError -> {
AlertManager.shared.showAlertMsg(generalGetString(R.string.error_deleting_link_for_group), "$r.chatError")
null
}
else -> {
Log.e(TAG, "apiDeleteGroupLink bad response: ${r.responseType} ${r.details}")
AlertManager.shared.showAlertMsg(
generalGetString(R.string.error_deleting_link_for_group),
"${r.responseType}: ${r.details}"
)
if (!(networkErrorAlert(r))) {
apiErrorAlert("apiDeleteGroupLink", generalGetString(R.string.error_deleting_link_for_group), r)
}
null
}
}