Final touches on rendering Zap Goals
This commit is contained in:
+1
-1
@@ -81,7 +81,7 @@ class NewGoalViewModel : ViewModel() {
|
||||
|
||||
val relays =
|
||||
account.outboxRelays.flow.value
|
||||
.map { it.url }
|
||||
.toList()
|
||||
|
||||
val closedAt = if (wantsDeadline) deadlineTimestamp else null
|
||||
val img = imageUrl.text.ifBlank { null }
|
||||
|
||||
+4
@@ -153,6 +153,7 @@ import com.vitorpamplona.amethyst.ui.note.types.RenderFhirResource
|
||||
import com.vitorpamplona.amethyst.ui.note.types.RenderGitIssueEvent
|
||||
import com.vitorpamplona.amethyst.ui.note.types.RenderGitPatchEvent
|
||||
import com.vitorpamplona.amethyst.ui.note.types.RenderGitRepositoryEvent
|
||||
import com.vitorpamplona.amethyst.ui.note.types.RenderGoal
|
||||
import com.vitorpamplona.amethyst.ui.note.types.RenderHighlight
|
||||
import com.vitorpamplona.amethyst.ui.note.types.RenderInteractiveStory
|
||||
import com.vitorpamplona.amethyst.ui.note.types.RenderLiveActivityChatMessage
|
||||
@@ -252,6 +253,7 @@ import com.vitorpamplona.quartz.nip71Video.VideoEvent
|
||||
import com.vitorpamplona.quartz.nip72ModCommunities.approval.CommunityPostApprovalEvent
|
||||
import com.vitorpamplona.quartz.nip72ModCommunities.communityAddress
|
||||
import com.vitorpamplona.quartz.nip72ModCommunities.isACommunityPost
|
||||
import com.vitorpamplona.quartz.nip75ZapGoals.GoalEvent
|
||||
import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent
|
||||
import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent
|
||||
import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent
|
||||
@@ -688,6 +690,8 @@ private fun FullBleedNoteCompose(
|
||||
RenderCalendarTimeSlotEvent(baseNote, accountViewModel, nav)
|
||||
} else if (noteEvent is CalendarDateSlotEvent) {
|
||||
RenderCalendarDateSlotEvent(baseNote, accountViewModel, nav)
|
||||
} else if (noteEvent is GoalEvent) {
|
||||
RenderGoal(baseNote, accountViewModel, nav)
|
||||
} else if (noteEvent is CommentEvent) {
|
||||
RenderTextEvent(
|
||||
baseNote,
|
||||
|
||||
@@ -22,7 +22,6 @@ package com.vitorpamplona.quartz.nip75ZapGoals
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import com.vitorpamplona.quartz.nip01Core.core.AddressableEvent
|
||||
import com.vitorpamplona.quartz.nip01Core.core.BaseAddressableEvent
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
|
||||
@@ -30,6 +29,7 @@ import com.vitorpamplona.quartz.nip01Core.hints.AddressHintProvider
|
||||
import com.vitorpamplona.quartz.nip01Core.hints.EventHintBundle
|
||||
import com.vitorpamplona.quartz.nip01Core.hints.EventHintProvider
|
||||
import com.vitorpamplona.quartz.nip01Core.hints.PubKeyHintProvider
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
||||
import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.aTag.ATag
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.aTag.toATag
|
||||
@@ -54,7 +54,7 @@ class GoalEvent(
|
||||
tags: Array<Array<String>>,
|
||||
content: String,
|
||||
sig: HexKey,
|
||||
) : BaseAddressableEvent(id, pubKey, createdAt, KIND, tags, content, sig),
|
||||
) : Event(id, pubKey, createdAt, KIND, tags, content, sig),
|
||||
EventHintProvider,
|
||||
AddressHintProvider,
|
||||
PubKeyHintProvider {
|
||||
@@ -89,7 +89,7 @@ class GoalEvent(
|
||||
fun build(
|
||||
description: String,
|
||||
amount: Long,
|
||||
relays: List<String>,
|
||||
relays: List<NormalizedRelayUrl>,
|
||||
closedAt: Long? = null,
|
||||
image: String? = null,
|
||||
summary: String? = null,
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@
|
||||
package com.vitorpamplona.quartz.nip75ZapGoals
|
||||
|
||||
import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.aTag.ATag
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.events.ETag
|
||||
import com.vitorpamplona.quartz.nip23LongContent.tags.ImageTag
|
||||
@@ -31,7 +32,7 @@ import com.vitorpamplona.quartz.nip75ZapGoals.tags.RelayListTag
|
||||
|
||||
fun TagArrayBuilder<GoalEvent>.amount(amountInMillisats: Long) = addUnique(AmountTag.assemble(amountInMillisats))
|
||||
|
||||
fun TagArrayBuilder<GoalEvent>.relays(urls: List<String>) = add(RelayListTag.assemble(urls))
|
||||
fun TagArrayBuilder<GoalEvent>.relays(urls: List<NormalizedRelayUrl>) = add(RelayListTag.assemble(urls))
|
||||
|
||||
fun TagArrayBuilder<GoalEvent>.summary(summary: String) = addUnique(SummaryTag.assemble(summary))
|
||||
|
||||
|
||||
+5
-3
@@ -21,10 +21,12 @@
|
||||
package com.vitorpamplona.quartz.nip75ZapGoals.tags
|
||||
|
||||
import com.vitorpamplona.quartz.nip01Core.core.has
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.normalizeRelayUrlOrNull
|
||||
import com.vitorpamplona.quartz.utils.ensure
|
||||
|
||||
class RelayListTag(
|
||||
val relayUrls: List<String>,
|
||||
val relays: List<NormalizedRelayUrl>,
|
||||
) {
|
||||
companion object {
|
||||
const val TAG_NAME = "relays"
|
||||
@@ -35,12 +37,12 @@ class RelayListTag(
|
||||
ensure(tag[1].isNotEmpty()) { return null }
|
||||
val relays =
|
||||
tag.mapIndexedNotNull { index, s ->
|
||||
if (index == 0) null else s
|
||||
if (index == 0) null else s.normalizeRelayUrlOrNull()
|
||||
}
|
||||
return RelayListTag(relays)
|
||||
}
|
||||
|
||||
fun assemble(urls: List<String>) = arrayOf(TAG_NAME) + urls.toTypedArray()
|
||||
fun assemble(urls: List<NormalizedRelayUrl>) = arrayOf(TAG_NAME) + urls.map { it.url }.toTypedArray()
|
||||
|
||||
fun assemble(tag: RelayListTag) = assemble(tag.relayUrls)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user