From 3c6818a53216853e6aac8d228985fdaee9e5da2f Mon Sep 17 00:00:00 2001 From: Narasimha-sc <166327228+Narasimha-sc@users.noreply.github.com> Date: Sat, 17 Oct 2026 18:38:27 +0000 Subject: [PATCH] android, desktop: keep a channel being created from replacing members The members of a channel being created were kept in the same list as the open chat's members, so while a channel was being created with a group open (on desktop, next to it; on Android, a group opened from a notification during the creation), the group's info listed the channel's relays as its members, and kept them until the info was shown again, on desktop also after the creation was cancelled. Keep the members of the channel being created in their own list, which the creation screen reads for relay connection errors. --- .../kotlin/chat/simplex/common/model/ChatModel.kt | 7 +++++-- .../chat/simplex/common/views/newchat/AddChannelView.kt | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt index 3db735ecea..9e0f2bfcc0 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt @@ -167,6 +167,7 @@ object ChatModel { // rhId, chatId val deletedChats = mutableStateOf>>(emptyList()) val creatingChannelId = mutableStateOf(null) + val creatingChannelMembers = mutableStateOf>(emptyList()) val groupMembers = mutableStateOf>(emptyList()) val groupMembersIndexes = mutableStateOf>(emptyMap()) val membersLoaded = mutableStateOf(false) @@ -981,8 +982,10 @@ object ChatModel { updateGroup(rhId, groupInfo) return false } - // update current chat or channel being created - return if (chatId.value == groupInfo.id || creatingChannelId.value == groupInfo.id) { + if (creatingChannelId.value == groupInfo.id) { + creatingChannelMembers.value = creatingChannelMembers.value.filter { it.groupMemberId != member.groupMemberId } + member + } + return if (chatId.value == groupInfo.id) { if (groupMembers.value.isNotEmpty() && groupMembers.value.firstOrNull()?.groupId != groupInfo.groupId) { // stale data, should be cleared at that point, otherwise, duplicated items will be here which will produce crashes in LazyColumn groupMembers.value = emptyList() diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/newchat/AddChannelView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/newchat/AddChannelView.kt index 7ad3076640..c1f621e2d5 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/newchat/AddChannelView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/newchat/AddChannelView.kt @@ -141,6 +141,7 @@ fun AddChannelView(chatModel: ChatModel, rh: RemoteHostInfo?, close: () -> Unit, is ChatController.PublicGroupCreationResult.Created -> { withContext(Dispatchers.Main) { chatModel.chatsContext.updateGroup(rhId = rhId, result.groupInfo) + chatModel.creatingChannelMembers.value = emptyList() chatModel.creatingChannelId.value = result.groupInfo.id groupInfo.value = result.groupInfo groupLink.value = result.groupLink @@ -536,7 +537,7 @@ private fun ProgressStepView( } private fun relayMemberConnFailed(chatModel: ChatModel, relay: GroupRelay): String? { - return chatModel.groupMembers.value + return chatModel.creatingChannelMembers.value .firstOrNull { it.groupMemberId == relay.groupMemberId } ?.activeConn?.connFailedErr }