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:
Claude
2026-04-20 16:27:31 +00:00
parent 7e45042c27
commit b6e31b21c8
5 changed files with 21 additions and 16 deletions
@@ -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
}
}
@@ -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)