diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt index d26302f4f..050bf1ae1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt @@ -2313,12 +2313,30 @@ class Account( targetLeafIndex: Int, groupRelays: Set, ) { - val manager = marmotManager ?: return - if (!isWriteable()) return + Log.d("MarmotDbg") { + "removeMarmotGroupMember: group=${nostrGroupId.take(8)}… targetLeafIndex=$targetLeafIndex " + + "groupRelays=${groupRelays.size}" + } + val manager = + marmotManager ?: run { + Log.w("MarmotDbg") { "removeMarmotGroupMember: marmotManager is NULL — no-op" } + return + } + if (!isWriteable()) { + Log.w("MarmotDbg") { "removeMarmotGroupMember: account is not writeable — no-op" } + return + } val outbound = manager.removeMember(nostrGroupId, targetLeafIndex) + Log.d("MarmotDbg") { + "removeMarmotGroupMember: built commit kind=${outbound.signedEvent.kind} id=${outbound.signedEvent.id.take(8)}…" + } val chatroom = marmotGroupList.getOrCreateGroup(nostrGroupId) manager.syncMetadataTo(nostrGroupId, chatroom) + Log.d("MarmotDbg") { + "removeMarmotGroupMember: publishing commit id=${outbound.signedEvent.id.take(8)}… " + + "to ${groupRelays.size} relay(s): ${groupRelays.map { it.url }}" + } client.publish(outbound.signedEvent, groupRelays) } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotManager.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotManager.kt index d8a509ab8..06a132c53 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotManager.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotManager.kt @@ -566,9 +566,14 @@ class MarmotManager( chatroom.adminPubkeys.value = metadata.adminPubkeys chatroom.relays.value = metadata.relays } + val previousCount = chatroom.members.value.size val members = memberPubkeys(nostrGroupId) chatroom.members.value = members chatroom.memberCount.value = members.size + Log.d("MarmotDbg") { + "syncMetadataTo: group=${nostrGroupId.take(8)}… members $previousCount→${members.size} " + + "(leafs=${members.map { it.leafIndex }})" + } } }