From 68525b413129ecba55214ff1c49aeb5c58d77575 Mon Sep 17 00:00:00 2001 From: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com> Date: Thu, 15 Dec 2022 13:56:20 +0300 Subject: [PATCH] android: Show error instead of crashing after failed to parse chats (#1573) * android: Show error instead of crashing after failed to parse chats * Just for test * update strings * Revert "Just for test" This reverts commit f9c9a20ab63c01d89276c5e4a6054566d553f3c5. Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> --- .../src/main/java/chat/simplex/app/model/SimpleXAPI.kt | 9 ++++++--- apps/android/app/src/main/res/values/strings.xml | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt b/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt index ba9d002845..6293fc7726 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt @@ -404,14 +404,17 @@ open class ChatController(var ctrl: ChatCtrl?, val ntfManager: NtfManager, val a suspend fun apiGetChats(): List { val r = sendCmd(CC.ApiGetChats()) - if (r is CR.ApiChats ) return r.chats - throw Exception("failed getting the list of chats: ${r.responseType} ${r.details}") + if (r is CR.ApiChats) return r.chats + Log.e(TAG, "failed getting the list of chats: ${r.responseType} ${r.details}") + AlertManager.shared.showAlertMsg(generalGetString(R.string.failed_to_parse_chats_title), generalGetString(R.string.contact_developers)) + return emptyList() } suspend fun apiGetChat(type: ChatType, id: Long, pagination: ChatPagination = ChatPagination.Last(ChatPagination.INITIAL_COUNT), search: String = ""): Chat? { val r = sendCmd(CC.ApiGetChat(type, id, pagination, search)) - if (r is CR.ApiChat ) return r.chat + if (r is CR.ApiChat) return r.chat Log.e(TAG, "apiGetChat bad response: ${r.responseType} ${r.details}") + AlertManager.shared.showAlertMsg(generalGetString(R.string.failed_to_parse_chat_title), generalGetString(R.string.contact_developers)) return null } diff --git a/apps/android/app/src/main/res/values/strings.xml b/apps/android/app/src/main/res/values/strings.xml index c38fa57242..5820cd060c 100644 --- a/apps/android/app/src/main/res/values/strings.xml +++ b/apps/android/app/src/main/res/values/strings.xml @@ -57,6 +57,9 @@ Error saving SMP servers Make sure SMP server addresses are in correct format, line separated and are not duplicated. Error updating network configuration + Failed to load chat + Failed to load chats + Please update the app and contact developers. Connection timeout