mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-11-12 00:47:50 +00:00
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.
This commit is contained in:
1 parent
ceb13f3a0a
commit
3c6818a532
2 files changed
+7
-3
No files matched your search
+5
-2
@@ -167,6 +167,7 @@ object ChatModel {
|
||||
// rhId, chatId
|
||||
val deletedChats = mutableStateOf<List<Pair<Long?, String>>>(emptyList())
|
||||
val creatingChannelId = mutableStateOf<String?>(null)
|
||||
val creatingChannelMembers = mutableStateOf<List<GroupMember>>(emptyList())
|
||||
val groupMembers = mutableStateOf<List<GroupMember>>(emptyList())
|
||||
val groupMembersIndexes = mutableStateOf<Map<Long, Int>>(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()
|
||||
|
||||
+2
-1
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user