mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-27 21:06:21 +02:00
move GalleryUrl to GalleryListEvent, merge recent changes
This commit is contained in:
@@ -25,10 +25,11 @@ import com.vitorpamplona.amethyst.model.LocalCache
|
|||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.model.User
|
import com.vitorpamplona.amethyst.model.User
|
||||||
|
|
||||||
class UserProfileGalleryFeedFilter(val user: User, val account: Account) : FeedFilter<Note>() {
|
class UserProfileGalleryFeedFilter(
|
||||||
override fun feedKey(): String {
|
val user: User,
|
||||||
return account.userProfile().pubkeyHex + "-Gallery-" + user.pubkeyHex
|
val account: Account,
|
||||||
}
|
) : FeedFilter<Note>() {
|
||||||
|
override fun feedKey(): String = account.userProfile().pubkeyHex + "-Gallery-" + user.pubkeyHex
|
||||||
|
|
||||||
override fun feed(): List<Note> {
|
override fun feed(): List<Note> {
|
||||||
val notes =
|
val notes =
|
||||||
@@ -45,8 +46,7 @@ class UserProfileGalleryFeedFilter(val user: User, val account: Account) : FeedF
|
|||||||
// )!!
|
// )!!
|
||||||
it.url,
|
it.url,
|
||||||
)
|
)
|
||||||
}
|
}?.toSet()
|
||||||
?.toSet()
|
|
||||||
?: emptySet()
|
?: emptySet()
|
||||||
|
|
||||||
var finalnotes = setOf<Note>()
|
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.UserProfileAppRecommendationsFeedFilter
|
||||||
import com.vitorpamplona.amethyst.ui.dal.UserProfileBookmarksFeedFilter
|
import com.vitorpamplona.amethyst.ui.dal.UserProfileBookmarksFeedFilter
|
||||||
import com.vitorpamplona.amethyst.ui.dal.UserProfileConversationsFeedFilter
|
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.UserProfileNewThreadFeedFilter
|
||||||
import com.vitorpamplona.amethyst.ui.dal.UserProfileReportsFeedFilter
|
import com.vitorpamplona.amethyst.ui.dal.UserProfileReportsFeedFilter
|
||||||
import com.vitorpamplona.amethyst.ui.dal.VideoFeedFilter
|
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(
|
class NostrUserProfileBookmarksFeedViewModel(
|
||||||
val user: User,
|
val user: User,
|
||||||
val account: Account,
|
val account: Account,
|
||||||
|
@@ -451,8 +451,7 @@ private fun RenderSurface(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
).fillMaxHeight()
|
||||||
.fillMaxHeight()
|
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
RenderScreen(
|
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 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] }
|
override fun taggedUrls() = tags.filter { it.size > 1 && it[0] == "r" }.map { it[1] }
|
||||||
|
|
||||||
|
@@ -145,7 +145,7 @@ interface EventInterface {
|
|||||||
|
|
||||||
fun firstTaggedK(): Int?
|
fun firstTaggedK(): Int?
|
||||||
|
|
||||||
fun taggedGalleryEntries(): List<GalleryUrl>
|
fun taggedGalleryEntries(): List<GalleryListEvent.GalleryUrl>
|
||||||
|
|
||||||
fun taggedEmojis(): List<EmojiUrl>
|
fun taggedEmojis(): List<EmojiUrl>
|
||||||
|
|
||||||
|
@@ -139,4 +139,23 @@ class GalleryListEvent(
|
|||||||
signer.sign(createdAt, KIND, newTags, content, onReady)
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user