Refactor models to take into account mixed lists, due to misunderstanding on my part.

This commit is contained in:
KotlinGeekDev
2025-09-29 11:17:12 +01:00
parent d2d811f670
commit 80906f2c5a
3 changed files with 13 additions and 11 deletions
@@ -32,8 +32,9 @@ data class FollowSet(
val title: String,
val description: String?,
val visibility: SetVisibility,
val profiles: Set<String>,
) : NostrSet(setVisibility = visibility, content = profiles) {
val privateProfiles: Set<String> = emptySet(),
val publicProfiles: Set<String> = 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(),
)
}
}
@@ -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 =
@@ -22,11 +22,13 @@ package com.vitorpamplona.amethyst.model.nip51Lists.followSets
sealed class NostrSet(
val setVisibility: SetVisibility,
val content: Collection<String>,
val privateContent: Collection<String>,
val publicContent: Collection<String>,
)
class CuratedBookmarkSet(
val name: String,
val visibility: SetVisibility,
val setItems: List<String>,
) : NostrSet(visibility, setItems)
val privateSetItems: List<String>,
val publicSetItems: List<String>,
) : NostrSet(visibility, privateSetItems, publicSetItems)