mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-11-10 20:36:45 +01:00
Continue refactoring of models to make things correct.
This commit is contained in:
@@ -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<String> = emptySet(),
|
||||
val publicProfiles: Set<String> = 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(),
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -228,23 +228,25 @@ 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)),
|
||||
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,
|
||||
@@ -253,20 +255,6 @@ class PeopleListEvent(
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user