Refactor models to take into account mixed lists, due to misunderstanding on my part.
This commit is contained in:
+7
-7
@@ -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(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -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 =
|
||||||
|
|||||||
+5
-3
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user