From 45f58e34d545c74c5bccae6b5afc5113625e1226 Mon Sep 17 00:00:00 2001 From: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com> Date: Mon, 14 Aug 2023 23:19:16 +0300 Subject: [PATCH] multiplatform: do not close non-active chat on delete/leave (#2921) Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> --- .../kotlin/chat/simplex/common/views/chat/ChatInfoView.kt | 4 +++- .../simplex/common/views/chat/group/GroupChatInfoView.kt | 4 +++- .../simplex/common/views/chatlist/ChatListNavLinkView.kt | 8 ++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatInfoView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatInfoView.kt index 8dfa5e05f..e96907a46 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatInfoView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatInfoView.kt @@ -205,7 +205,9 @@ fun deleteContactDialog(chatInfo: ChatInfo, chatModel: ChatModel, close: (() -> val r = chatModel.controller.apiDeleteChat(chatInfo.chatType, chatInfo.apiId) if (r) { chatModel.removeChat(chatInfo.id) - chatModel.chatId.value = null + if (chatModel.chatId.value == chatInfo.id) { + chatModel.chatId.value = null + } ntfManager.cancelNotificationsForChat(chatInfo.id) close?.invoke() } diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupChatInfoView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupChatInfoView.kt index e5f63ed3e..b0dc7060a 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupChatInfoView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupChatInfoView.kt @@ -133,7 +133,9 @@ fun deleteGroupDialog(chatInfo: ChatInfo, groupInfo: GroupInfo, chatModel: ChatM val r = chatModel.controller.apiDeleteChat(chatInfo.chatType, chatInfo.apiId) if (r) { chatModel.removeChat(chatInfo.id) - chatModel.chatId.value = null + if (chatModel.chatId.value == chatInfo.id) { + chatModel.chatId.value = null + } ntfManager.cancelNotificationsForChat(chatInfo.id) close?.invoke() } diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListNavLinkView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListNavLinkView.kt index 5452bbba2..c84974137 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListNavLinkView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListNavLinkView.kt @@ -522,7 +522,9 @@ fun pendingContactAlertDialog(chatInfo: ChatInfo, chatModel: ChatModel) { val r = chatModel.controller.apiDeleteChat(chatInfo.chatType, chatInfo.apiId) if (r) { chatModel.removeChat(chatInfo.id) - chatModel.chatId.value = null + if (chatModel.chatId.value == chatInfo.id) { + chatModel.chatId.value = null + } } } }, @@ -555,7 +557,9 @@ fun deleteGroup(groupInfo: GroupInfo, chatModel: ChatModel) { val r = chatModel.controller.apiDeleteChat(ChatType.Group, groupInfo.apiId) if (r) { chatModel.removeChat(groupInfo.id) - chatModel.chatId.value = null + if (chatModel.chatId.value == groupInfo.id) { + chatModel.chatId.value = null + } ntfManager.cancelNotificationsForChat(groupInfo.id) } }