diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/followSets/FollowSet.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/followSets/FollowSet.kt index 91cd973a3..0ec59bfd3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/followSets/FollowSet.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/followSets/FollowSet.kt @@ -31,7 +31,7 @@ data class FollowSet( val identifierTag: String, val title: String, val description: String?, - val visibility: SetVisibility, + val visibility: SetVisibility = SetVisibility.Mixed, val privateProfiles: Set = emptySet(), val publicProfiles: Set = emptySet(), ) : NostrSet(setVisibility = visibility, privateContent = privateProfiles, publicContent = publicProfiles) { @@ -54,7 +54,6 @@ data class FollowSet( identifierTag = dTag, title = listTitle, description = listDescription, - visibility = SetVisibility.Private, privateProfiles = privateFollows.toSet(), ) } else if (publicFollows.isNotEmpty() && privateFollows.isEmpty()) { @@ -62,7 +61,6 @@ data class FollowSet( identifierTag = dTag, title = listTitle, description = listDescription, - visibility = SetVisibility.Public, publicProfiles = publicFollows.toSet(), ) } else { @@ -70,7 +68,6 @@ data class FollowSet( identifierTag = dTag, title = listTitle, description = listDescription, - visibility = SetVisibility.Public, privateProfiles = privateFollows.toSet(), publicProfiles = publicFollows.toSet(), ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/FollowSetFeedViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/FollowSetFeedViewModel.kt index c921816cf..4cb41e16b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/FollowSetFeedViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/FollowSetFeedViewModel.kt @@ -31,7 +31,6 @@ import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.model.AddressableNote import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.amethyst.model.nip51Lists.followSets.FollowSet -import com.vitorpamplona.amethyst.model.nip51Lists.followSets.SetVisibility import com.vitorpamplona.amethyst.service.checkNotInMainThread import com.vitorpamplona.amethyst.ui.dal.FeedFilter import com.vitorpamplona.amethyst.ui.dal.FollowSetFeedFilter @@ -117,8 +116,8 @@ class FollowSetFeedViewModel( fun addFollowSet( setName: String, setDescription: String?, - isListPrivate: Boolean, optionalFirstMemberHex: String? = null, + firstMemberShouldBePrivate: Boolean = false, account: Account, ) { if (!account.settings.isWriteable()) { @@ -129,7 +128,7 @@ class FollowSetFeedViewModel( dTag = UUID.randomUUID().toString(), title = setName, description = setDescription, - isPrivate = isListPrivate, + isPrivate = firstMemberShouldBePrivate, firstMemberHex = optionalFirstMemberHex, signer = account.signer, ) { @@ -179,6 +178,7 @@ class FollowSetFeedViewModel( fun addUserToSet( userProfileHex: String, followSet: FollowSet, + shouldBePrivateMember: Boolean, account: Account, ) { if (!account.settings.isWriteable()) { @@ -190,7 +190,7 @@ class FollowSetFeedViewModel( PeopleListEvent.addUser( earlierVersion = followSetEvent, pubKeyHex = userProfileHex, - isPrivate = followSet.visibility == SetVisibility.Private, + isPrivate = shouldBePrivateMember, signer = account.signer, ) { account.sendMyPublicAndPrivateOutbox(it) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/PeopleListEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/PeopleListEvent.kt index 48ec42f8b..1d2c4c9f1 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/PeopleListEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/PeopleListEvent.kt @@ -228,45 +228,33 @@ class PeopleListEvent( createdAt: Long = TimeUtils.now(), onReady: (PeopleListEvent) -> Unit, ) { + val isFirstMemberSpecified = firstMemberHex != null if (description == null) { - val newList = - create( + val newListTemplate = + build( name = title, - person = UserTag(pubKey = firstMemberHex ?: signer.pubKey), - isPrivate = isPrivate, + publicPeople = if (!isPrivate && isFirstMemberSpecified) listOf(UserTag(pubKey = firstMemberHex)) else emptyList(), + privatePeople = if (isPrivate && isFirstMemberSpecified) listOf(UserTag(pubKey = firstMemberHex)) else emptyList(), signer = signer, dTag = dTag, createdAt = createdAt, ) + val newList = signer.sign(newListTemplate) onReady(newList) } else { - if (isPrivate) { - val event = - build( - name = title, - privatePeople = listOf(UserTag(pubKey = firstMemberHex ?: signer.pubKey)), - signer = signer, - dTag = dTag, - createdAt = createdAt, - ) { - addUnique(arrayOf("description", description)) - } - val list = signer.sign(event) - onReady(list) - } else { - val event = - build( - name = title, - publicPeople = listOf(UserTag(pubKey = firstMemberHex ?: signer.pubKey)), - signer = signer, - dTag = dTag, - createdAt = createdAt, - ) { - addUnique(arrayOf("description", description)) - } - val list = signer.sign(event) - onReady(list) - } + val event = + build( + name = title, + publicPeople = if (!isPrivate && isFirstMemberSpecified) listOf(UserTag(pubKey = firstMemberHex)) else emptyList(), + privatePeople = if (isPrivate && isFirstMemberSpecified) listOf(UserTag(pubKey = firstMemberHex)) else emptyList(), + signer = signer, + dTag = dTag, + createdAt = createdAt, + ) { + addUnique(arrayOf("description", description)) + } + val list = signer.sign(event) + onReady(list) } }