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 title: String,
val description: String?, val description: String?,
val visibility: SetVisibility, val visibility: SetVisibility,
val profiles: Set<String>, val privateProfiles: Set<String> = emptySet(),
) : NostrSet(setVisibility = visibility, content = profiles) { val publicProfiles: Set<String> = emptySet(),
) : NostrSet(setVisibility = visibility, privateContent = privateProfiles, publicContent = publicProfiles) {
companion object { companion object {
fun mapEventToSet( fun mapEventToSet(
event: PeopleListEvent, event: PeopleListEvent,
@@ -54,7 +55,7 @@ data class FollowSet(
title = listTitle, title = listTitle,
description = listDescription, description = listDescription,
visibility = SetVisibility.Private, visibility = SetVisibility.Private,
profiles = privateFollows.toSet(), privateProfiles = privateFollows.toSet(),
) )
} else if (publicFollows.isNotEmpty() && privateFollows.isEmpty()) { } else if (publicFollows.isNotEmpty() && privateFollows.isEmpty()) {
FollowSet( FollowSet(
@@ -62,17 +63,16 @@ data class FollowSet(
title = listTitle, title = listTitle,
description = listDescription, description = listDescription,
visibility = SetVisibility.Public, visibility = SetVisibility.Public,
profiles = publicFollows.toSet(), publicProfiles = publicFollows.toSet(),
) )
} else { } else {
// Follow set is empty, so assume public. Why? Nostr limitation.
// TODO: Could this be fixed at protocol level?
FollowSet( FollowSet(
identifierTag = dTag, identifierTag = dTag,
title = listTitle, title = listTitle,
description = listDescription, description = listDescription,
visibility = SetVisibility.Public, visibility = SetVisibility.Public,
profiles = publicFollows.toSet(), privateProfiles = privateFollows.toSet(),
publicProfiles = publicFollows.toSet(),
) )
} }
} }
@@ -68,7 +68,7 @@ class FollowSetState(
val profilesFlow = val profilesFlow =
getFollowSetNotesFlow() getFollowSetNotesFlow()
.map { it -> .map { it ->
it.flatMapTo(mutableSetOf()) { it.profiles }.toSet() it.flatMapTo(mutableSetOf()) { it.privateProfiles + it.publicProfiles }.toSet()
}.stateIn(scope, SharingStarted.Eagerly, emptySet()) }.stateIn(scope, SharingStarted.Eagerly, emptySet())
fun mapNoteToFollowSet(note: Note): FollowSet = fun mapNoteToFollowSet(note: Note): FollowSet =
@@ -22,11 +22,13 @@ package com.vitorpamplona.amethyst.model.nip51Lists.followSets
sealed class NostrSet( sealed class NostrSet(
val setVisibility: SetVisibility, val setVisibility: SetVisibility,
val content: Collection<String>, val privateContent: Collection<String>,
val publicContent: Collection<String>,
) )
class CuratedBookmarkSet( class CuratedBookmarkSet(
val name: String, val name: String,
val visibility: SetVisibility, val visibility: SetVisibility,
val setItems: List<String>, val privateSetItems: List<String>,
) : NostrSet(visibility, setItems) val publicSetItems: List<String>,
) : NostrSet(visibility, privateSetItems, publicSetItems)