refactor: make Marmot group members list reactive
Expose the member list as MutableStateFlow<List<GroupMemberInfo>> on MarmotGroupChatroom, populated by MarmotManager.syncMetadataTo alongside the existing memberCount. MarmotGroupInfoScreen and RemoveMemberScreen now observe it via collectAsStateWithLifecycle, so both remote commits (already routed through syncMetadataTo in DecryptAndIndexProcessor) and local mutations refresh the UI without manual re-queries. Account.addMarmotGroupMember and removeMarmotGroupMember now call syncMetadataTo right after the MLS state is mutated, mirroring the pattern already used by updateMarmotGroupMetadata, so the local change is visible immediately without waiting for the relay round-trip.
This commit is contained in:
+3
-1
@@ -437,7 +437,9 @@ class MarmotManager(
|
||||
chatroom.adminPubkeys.value = metadata.adminPubkeys
|
||||
chatroom.relays.value = metadata.relays
|
||||
}
|
||||
chatroom.memberCount.value = memberCount(nostrGroupId)
|
||||
val members = memberPubkeys(nostrGroupId)
|
||||
chatroom.members.value = members
|
||||
chatroom.memberCount.value = members.size
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -21,6 +21,7 @@
|
||||
package com.vitorpamplona.amethyst.commons.model.marmotGroups
|
||||
|
||||
import androidx.compose.runtime.Stable
|
||||
import com.vitorpamplona.amethyst.commons.marmot.GroupMemberInfo
|
||||
import com.vitorpamplona.amethyst.commons.model.Channel.Companion.DefaultFeedOrder
|
||||
import com.vitorpamplona.amethyst.commons.model.ListChange
|
||||
import com.vitorpamplona.amethyst.commons.model.Note
|
||||
@@ -46,6 +47,7 @@ class MarmotGroupChatroom(
|
||||
var adminPubkeys = MutableStateFlow<List<HexKey>>(emptyList())
|
||||
var relays = MutableStateFlow<List<String>>(emptyList())
|
||||
var memberCount = MutableStateFlow(0)
|
||||
var members = MutableStateFlow<List<GroupMemberInfo>>(emptyList())
|
||||
var newestMessage: Note? = null
|
||||
val unreadCount = MutableStateFlow(0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user