kopia lustrzana https://github.com/vitorpamplona/amethyst
move GalleryUrl to GalleryListEvent, merge recent changes
rodzic
4bda6fa0cc
commit
9b26bdac5c
|
@ -25,10 +25,11 @@ import com.vitorpamplona.amethyst.model.LocalCache
|
|||
import com.vitorpamplona.amethyst.model.Note
|
||||
import com.vitorpamplona.amethyst.model.User
|
||||
|
||||
class UserProfileGalleryFeedFilter(val user: User, val account: Account) : FeedFilter<Note>() {
|
||||
override fun feedKey(): String {
|
||||
return account.userProfile().pubkeyHex + "-Gallery-" + user.pubkeyHex
|
||||
}
|
||||
class UserProfileGalleryFeedFilter(
|
||||
val user: User,
|
||||
val account: Account,
|
||||
) : FeedFilter<Note>() {
|
||||
override fun feedKey(): String = account.userProfile().pubkeyHex + "-Gallery-" + user.pubkeyHex
|
||||
|
||||
override fun feed(): List<Note> {
|
||||
val notes =
|
||||
|
@ -45,8 +46,7 @@ class UserProfileGalleryFeedFilter(val user: User, val account: Account) : FeedF
|
|||
// )!!
|
||||
it.url,
|
||||
)
|
||||
}
|
||||
?.toSet()
|
||||
}?.toSet()
|
||||
?: emptySet()
|
||||
|
||||
var finalnotes = setOf<Note>()
|
||||
|
|
|
@ -57,6 +57,7 @@ import com.vitorpamplona.amethyst.ui.dal.ThreadFeedFilter
|
|||
import com.vitorpamplona.amethyst.ui.dal.UserProfileAppRecommendationsFeedFilter
|
||||
import com.vitorpamplona.amethyst.ui.dal.UserProfileBookmarksFeedFilter
|
||||
import com.vitorpamplona.amethyst.ui.dal.UserProfileConversationsFeedFilter
|
||||
import com.vitorpamplona.amethyst.ui.dal.UserProfileGalleryFeedFilter
|
||||
import com.vitorpamplona.amethyst.ui.dal.UserProfileNewThreadFeedFilter
|
||||
import com.vitorpamplona.amethyst.ui.dal.UserProfileReportsFeedFilter
|
||||
import com.vitorpamplona.amethyst.ui.dal.VideoFeedFilter
|
||||
|
@ -248,6 +249,20 @@ class NostrUserProfileReportFeedViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
class NostrUserProfileGalleryFeedViewModel(
|
||||
val user: User,
|
||||
val account: Account,
|
||||
) : FeedViewModel(UserProfileGalleryFeedFilter(user, account)) {
|
||||
class Factory(
|
||||
val user: User,
|
||||
val account: Account,
|
||||
) : ViewModelProvider.Factory {
|
||||
override fun <NostrUserProfileGalleryFeedViewModel : ViewModel> create(modelClass: Class<NostrUserProfileGalleryFeedViewModel>): NostrUserProfileGalleryFeedViewModel =
|
||||
NostrUserProfileGalleryFeedViewModel(user, account)
|
||||
as NostrUserProfileGalleryFeedViewModel
|
||||
}
|
||||
}
|
||||
|
||||
class NostrUserProfileBookmarksFeedViewModel(
|
||||
val user: User,
|
||||
val account: Account,
|
||||
|
|
|
@ -451,8 +451,7 @@ private fun RenderSurface(
|
|||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
.fillMaxHeight()
|
||||
).fillMaxHeight()
|
||||
},
|
||||
) {
|
||||
RenderScreen(
|
||||
|
|
|
@ -73,21 +73,3 @@ data class EmojiUrl(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Immutable
|
||||
data class GalleryUrl(val id: String, val url: String) {
|
||||
fun encode(): String {
|
||||
return ":$id:$url"
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun decode(encodedGallerySetup: String): EmojiUrl? {
|
||||
val emojiParts = encodedGallerySetup.split(":", limit = 3)
|
||||
return if (emojiParts.size > 2) {
|
||||
EmojiUrl(emojiParts[1], emojiParts[2])
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ open class Event(
|
|||
|
||||
override fun taggedEvents() = tags.filter { it.size > 1 && it[0] == "e" }.map { it[1] }
|
||||
|
||||
override fun taggedGalleryEntries() = tags.filter { it.size > 2 && it[0] == GalleryListEvent.GALLERYTAGNAME }.map { GalleryUrl(it[1], it[2]) }
|
||||
override fun taggedGalleryEntries() = tags.filter { it.size > 2 && it[0] == GalleryListEvent.GALLERYTAGNAME }.map { GalleryListEvent.GalleryUrl(it[1], it[2]) }
|
||||
|
||||
override fun taggedUrls() = tags.filter { it.size > 1 && it[0] == "r" }.map { it[1] }
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ interface EventInterface {
|
|||
|
||||
fun firstTaggedK(): Int?
|
||||
|
||||
fun taggedGalleryEntries(): List<GalleryUrl>
|
||||
fun taggedGalleryEntries(): List<GalleryListEvent.GalleryUrl>
|
||||
|
||||
fun taggedEmojis(): List<EmojiUrl>
|
||||
|
||||
|
|
|
@ -139,4 +139,23 @@ class GalleryListEvent(
|
|||
signer.sign(createdAt, KIND, newTags, content, onReady)
|
||||
}
|
||||
}
|
||||
|
||||
@Immutable
|
||||
data class GalleryUrl(
|
||||
val id: String,
|
||||
val url: String,
|
||||
) {
|
||||
fun encode(): String = ":$id:$url"
|
||||
|
||||
companion object {
|
||||
fun decode(encodedGallerySetup: String): EmojiUrl? {
|
||||
val emojiParts = encodedGallerySetup.split(":", limit = 3)
|
||||
return if (emojiParts.size > 2) {
|
||||
EmojiUrl(emojiParts[1], emojiParts[2])
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue