From 80906f2c5a67aa43909bd3a85dfcac8d76686b3a Mon Sep 17 00:00:00 2001 From: KotlinGeekDev Date: Mon, 29 Sep 2025 11:17:12 +0100 Subject: [PATCH] Refactor models to take into account mixed lists, due to misunderstanding on my part. --- .../model/nip51Lists/followSets/FollowSet.kt | 14 +++++++------- .../model/nip51Lists/followSets/FollowSetState.kt | 2 +- .../model/nip51Lists/followSets/NostrSet.kt | 8 +++++--- 3 files changed, 13 insertions(+), 11 deletions(-) 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 59f5ed34c..91cd973a3 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 @@ -32,8 +32,9 @@ data class FollowSet( val title: String, val description: String?, val visibility: SetVisibility, - val profiles: Set, -) : NostrSet(setVisibility = visibility, content = profiles) { + val privateProfiles: Set = emptySet(), + val publicProfiles: Set = emptySet(), +) : NostrSet(setVisibility = visibility, privateContent = privateProfiles, publicContent = publicProfiles) { companion object { fun mapEventToSet( event: PeopleListEvent, @@ -54,7 +55,7 @@ data class FollowSet( title = listTitle, description = listDescription, visibility = SetVisibility.Private, - profiles = privateFollows.toSet(), + privateProfiles = privateFollows.toSet(), ) } else if (publicFollows.isNotEmpty() && privateFollows.isEmpty()) { FollowSet( @@ -62,17 +63,16 @@ data class FollowSet( title = listTitle, description = listDescription, visibility = SetVisibility.Public, - profiles = publicFollows.toSet(), + publicProfiles = publicFollows.toSet(), ) } else { - // Follow set is empty, so assume public. Why? Nostr limitation. - // TODO: Could this be fixed at protocol level? FollowSet( identifierTag = dTag, title = listTitle, description = listDescription, visibility = SetVisibility.Public, - profiles = publicFollows.toSet(), + privateProfiles = privateFollows.toSet(), + publicProfiles = publicFollows.toSet(), ) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/followSets/FollowSetState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/followSets/FollowSetState.kt index 120c651a1..d12f6a9d8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/followSets/FollowSetState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/followSets/FollowSetState.kt @@ -68,7 +68,7 @@ class FollowSetState( val profilesFlow = getFollowSetNotesFlow() .map { it -> - it.flatMapTo(mutableSetOf()) { it.profiles }.toSet() + it.flatMapTo(mutableSetOf()) { it.privateProfiles + it.publicProfiles }.toSet() }.stateIn(scope, SharingStarted.Eagerly, emptySet()) fun mapNoteToFollowSet(note: Note): FollowSet = diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/followSets/NostrSet.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/followSets/NostrSet.kt index aadae3380..13295f7c9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/followSets/NostrSet.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/followSets/NostrSet.kt @@ -22,11 +22,13 @@ package com.vitorpamplona.amethyst.model.nip51Lists.followSets sealed class NostrSet( val setVisibility: SetVisibility, - val content: Collection, + val privateContent: Collection, + val publicContent: Collection, ) class CuratedBookmarkSet( val name: String, val visibility: SetVisibility, - val setItems: List, -) : NostrSet(visibility, setItems) + val privateSetItems: List, + val publicSetItems: List, +) : NostrSet(visibility, privateSetItems, publicSetItems)