Move FollowSet to it's own class.
This commit is contained in:
@@ -21,7 +21,6 @@
|
||||
package com.vitorpamplona.quartz.events
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.runtime.Stable
|
||||
import com.vitorpamplona.quartz.encoders.HexKey
|
||||
import com.vitorpamplona.quartz.signers.NostrSigner
|
||||
import com.vitorpamplona.quartz.utils.TimeUtils
|
||||
@@ -77,45 +76,6 @@ class PeopleListEvent(
|
||||
}
|
||||
}
|
||||
|
||||
@Stable
|
||||
class FollowSet(
|
||||
val isPrivate: Boolean,
|
||||
val title: String,
|
||||
val description: String?,
|
||||
val profileList: Set<String>,
|
||||
) {
|
||||
companion object {
|
||||
fun mapEventToSet(
|
||||
event: PeopleListEvent,
|
||||
signer: NostrSigner,
|
||||
): FollowSet {
|
||||
val dTag = event.dTag()
|
||||
val listTitle = event.title() ?: dTag
|
||||
val listDescription = event.description() ?: ""
|
||||
val publicFollows = event.filterTagList("p", null)
|
||||
val privateFollows = mutableListOf<String>()
|
||||
event.privateTaggedUsers(signer) { userList -> privateFollows.addAll(userList) }
|
||||
return if (publicFollows.isEmpty() && privateFollows.isNotEmpty()) {
|
||||
FollowSet(
|
||||
isPrivate = true,
|
||||
title = listTitle,
|
||||
description = listDescription,
|
||||
profileList = privateFollows.toSet(),
|
||||
)
|
||||
} else if (publicFollows.isNotEmpty() && privateFollows.isEmpty()) {
|
||||
FollowSet(
|
||||
isPrivate = false,
|
||||
title = listTitle,
|
||||
description = listDescription,
|
||||
profileList = publicFollows.toSet(),
|
||||
)
|
||||
} else {
|
||||
throw Exception("Mixed follow sets are not yet supported.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Immutable
|
||||
class UsersAndWords(
|
||||
val users: Set<String> = setOf(),
|
||||
|
||||
Reference in New Issue
Block a user