mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-11-10 18:16:46 +01:00
Make a method specially for cloning/copying. Refactor createListWithDescription().
This commit is contained in:
@@ -191,11 +191,10 @@ class FollowSetFeedViewModel(
|
|||||||
println("You are in read-only mode. Please login to make modifications.")
|
println("You are in read-only mode. Please login to make modifications.")
|
||||||
} else {
|
} else {
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
PeopleListEvent.createListWithDescription(
|
PeopleListEvent.copy(
|
||||||
dTag = UUID.randomUUID().toString(),
|
dTag = UUID.randomUUID().toString(),
|
||||||
title = customCloneName ?: currentFollowSet.title,
|
title = customCloneName ?: currentFollowSet.title,
|
||||||
description = customCloneDescription ?: currentFollowSet.description,
|
description = customCloneDescription ?: currentFollowSet.description,
|
||||||
isPrivate = false,
|
|
||||||
firstPublicMembers = currentFollowSet.publicProfiles.toList(),
|
firstPublicMembers = currentFollowSet.publicProfiles.toList(),
|
||||||
firstPrivateMembers = currentFollowSet.privateProfiles.toList(),
|
firstPrivateMembers = currentFollowSet.privateProfiles.toList(),
|
||||||
signer = account.signer,
|
signer = account.signer,
|
||||||
|
|||||||
@@ -229,7 +229,6 @@ class PeopleListEvent(
|
|||||||
createdAt: Long = TimeUtils.now(),
|
createdAt: Long = TimeUtils.now(),
|
||||||
onReady: (PeopleListEvent) -> Unit,
|
onReady: (PeopleListEvent) -> Unit,
|
||||||
) {
|
) {
|
||||||
if (description == null) {
|
|
||||||
val newListTemplate =
|
val newListTemplate =
|
||||||
build(
|
build(
|
||||||
name = title,
|
name = title,
|
||||||
@@ -248,34 +247,37 @@ class PeopleListEvent(
|
|||||||
signer = signer,
|
signer = signer,
|
||||||
dTag = dTag,
|
dTag = dTag,
|
||||||
createdAt = createdAt,
|
createdAt = createdAt,
|
||||||
)
|
) {
|
||||||
|
if (description != null) addUnique(DescriptionTag.assemble(description))
|
||||||
|
}
|
||||||
val newList = signer.sign(newListTemplate)
|
val newList = signer.sign(newListTemplate)
|
||||||
onReady(newList)
|
onReady(newList)
|
||||||
} else {
|
}
|
||||||
val event =
|
|
||||||
|
suspend fun copy(
|
||||||
|
dTag: String,
|
||||||
|
title: String,
|
||||||
|
description: String? = null,
|
||||||
|
firstPublicMembers: List<String> = emptyList(),
|
||||||
|
firstPrivateMembers: List<String> = emptyList(),
|
||||||
|
signer: NostrSigner,
|
||||||
|
createdAt: Long = TimeUtils.now(),
|
||||||
|
onReady: (PeopleListEvent) -> Unit,
|
||||||
|
) {
|
||||||
|
val cloneTemplate =
|
||||||
build(
|
build(
|
||||||
name = title,
|
name = title,
|
||||||
publicPeople =
|
publicPeople = firstPublicMembers.map { UserTag(pubKey = it) },
|
||||||
if (!isPrivate && firstPublicMembers.isNotEmpty()) {
|
privatePeople = firstPrivateMembers.map { UserTag(pubKey = it) },
|
||||||
firstPublicMembers.map { UserTag(pubKey = it) }
|
|
||||||
} else {
|
|
||||||
emptyList()
|
|
||||||
},
|
|
||||||
privatePeople =
|
|
||||||
if (isPrivate && firstPrivateMembers.isNotEmpty()) {
|
|
||||||
firstPrivateMembers.map { UserTag(pubKey = it) }
|
|
||||||
} else {
|
|
||||||
emptyList()
|
|
||||||
},
|
|
||||||
signer = signer,
|
signer = signer,
|
||||||
dTag = dTag,
|
dTag = dTag,
|
||||||
createdAt = createdAt,
|
createdAt = createdAt,
|
||||||
) {
|
) {
|
||||||
addUnique(DescriptionTag.assemble(description))
|
if (description != null) addUnique(DescriptionTag.assemble(description))
|
||||||
}
|
|
||||||
val list = signer.sign(event)
|
|
||||||
onReady(list)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val listClone = signer.sign(cloneTemplate)
|
||||||
|
onReady(listClone)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun createListWithUser(
|
suspend fun createListWithUser(
|
||||||
|
|||||||
Reference in New Issue
Block a user