From b3e3b70dd0534560e34523ee4563028910f51f88 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Tue, 19 Nov 2024 18:01:56 -0500 Subject: [PATCH] Marks which events can receive Comment replies as root scopes. --- .../com/vitorpamplona/amethyst/ui/actions/NewPostViewModel.kt | 3 ++- .../main/java/com/vitorpamplona/quartz/events/CommentEvent.kt | 3 ++- quartz/src/main/java/com/vitorpamplona/quartz/events/Event.kt | 2 ++ .../main/java/com/vitorpamplona/quartz/events/PictureEvent.kt | 3 ++- .../main/java/com/vitorpamplona/quartz/events/VideoEvent.kt | 3 ++- .../java/com/vitorpamplona/quartz/events/VideoVerticalEvent.kt | 3 ++- 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostViewModel.kt index 6dc82848d..b36fa579d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostViewModel.kt @@ -70,6 +70,7 @@ import com.vitorpamplona.quartz.events.FileStorageHeaderEvent import com.vitorpamplona.quartz.events.GitIssueEvent import com.vitorpamplona.quartz.events.Price import com.vitorpamplona.quartz.events.PrivateDmEvent +import com.vitorpamplona.quartz.events.RootScope import com.vitorpamplona.quartz.events.TextNoteEvent import com.vitorpamplona.quartz.events.TorrentCommentEvent import com.vitorpamplona.quartz.events.TorrentEvent @@ -555,7 +556,7 @@ open class NewPostViewModel : ViewModel() { val replyingTo = originalNote - if (replyingTo?.event is CommentEvent || replyingTo?.event is Event) { + if (replyingTo?.event is CommentEvent || (replyingTo?.event is Event && replyingTo.event is RootScope)) { account?.sendReplyComment( message = tagger.message, replyingTo = replyingTo, diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/events/CommentEvent.kt b/quartz/src/main/java/com/vitorpamplona/quartz/events/CommentEvent.kt index 90d2ef0d5..671308802 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/events/CommentEvent.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/events/CommentEvent.kt @@ -39,7 +39,8 @@ class CommentEvent( tags: Array>, content: String, sig: HexKey, -) : BaseTextNoteEvent(id, pubKey, createdAt, KIND, tags, content, sig) { +) : BaseTextNoteEvent(id, pubKey, createdAt, KIND, tags, content, sig), + RootScope { fun root() = tags.firstOrNull { it.size > 3 && it[3] == "root" }?.get(1) fun getRootScopes() = tags.filter { it.size > 1 && it[0] == "I" || it[0] == "A" || it[0] == "E" } diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/events/Event.kt b/quartz/src/main/java/com/vitorpamplona/quartz/events/Event.kt index 708045c0f..bb2ee18d2 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/events/Event.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/events/Event.kt @@ -588,3 +588,5 @@ data class ZapSplitSetup( val weight: Double, val isLnAddress: Boolean, ) + +interface RootScope diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/events/PictureEvent.kt b/quartz/src/main/java/com/vitorpamplona/quartz/events/PictureEvent.kt index 707ae1212..75048d080 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/events/PictureEvent.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/events/PictureEvent.kt @@ -38,7 +38,8 @@ class PictureEvent( tags: Array>, content: String, sig: HexKey, -) : Event(id, pubKey, createdAt, KIND, tags, content, sig) { +) : Event(id, pubKey, createdAt, KIND, tags, content, sig), + RootScope { fun mimeTypes() = tags.filter { it.size > 1 && it[0] == MIME_TYPE } fun hashes() = tags.filter { it.size > 1 && it[0] == HASH } diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/events/VideoEvent.kt b/quartz/src/main/java/com/vitorpamplona/quartz/events/VideoEvent.kt index 2fc08d3d7..97f00d944 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/events/VideoEvent.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/events/VideoEvent.kt @@ -34,7 +34,8 @@ abstract class VideoEvent( tags: Array>, content: String, sig: HexKey, -) : BaseAddressableEvent(id, pubKey, createdAt, kind, tags, content, sig) { +) : BaseAddressableEvent(id, pubKey, createdAt, kind, tags, content, sig), + RootScope { fun url() = tags.firstOrNull { it.size > 1 && it[0] == URL }?.get(1) fun urls() = tags.filter { it.size > 1 && it[0] == URL }.map { it[1] } diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/events/VideoVerticalEvent.kt b/quartz/src/main/java/com/vitorpamplona/quartz/events/VideoVerticalEvent.kt index 2ed43e2de..598051cca 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/events/VideoVerticalEvent.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/events/VideoVerticalEvent.kt @@ -34,7 +34,8 @@ class VideoVerticalEvent( tags: Array>, content: String, sig: HexKey, -) : VideoEvent(id, pubKey, createdAt, KIND, tags, content, sig) { +) : VideoEvent(id, pubKey, createdAt, KIND, tags, content, sig), + RootScope { companion object { const val KIND = 34236 const val ALT_DESCRIPTION = "Vertical Video"