mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-03-28 18:51:45 +01:00
Uses note.toEventUri to make sure the relay hint is correct
Avoids crash when adding an event to gallery without a relay hint.
This commit is contained in:
parent
a2d9f31a8a
commit
d5d289a834
@ -679,7 +679,7 @@ fun ShareImageAction(
|
|||||||
if (videoUri != null) {
|
if (videoUri != null) {
|
||||||
val n19 = Nip19Parser.uriToRoute(postNostrUri)?.entity as? NEvent
|
val n19 = Nip19Parser.uriToRoute(postNostrUri)?.entity as? NEvent
|
||||||
if (n19 != null) {
|
if (n19 != null) {
|
||||||
accountViewModel.addMediaToGallery(n19.hex, videoUri, n19.relay[0], blurhash, dim, hash, mimeType) // TODO Whole list or first?
|
accountViewModel.addMediaToGallery(n19.hex, videoUri, n19.relay.getOrNull(0), blurhash, dim, hash, mimeType) // TODO Whole list or first?
|
||||||
accountViewModel.toast(R.string.media_added, R.string.media_added_to_profile_gallery)
|
accountViewModel.toast(R.string.media_added, R.string.media_added_to_profile_gallery)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ fun RenderEncryptedFile(
|
|||||||
hash = noteEvent.originalHash(),
|
hash = noteEvent.originalHash(),
|
||||||
blurhash = noteEvent.blurhash(),
|
blurhash = noteEvent.blurhash(),
|
||||||
dim = noteEvent.dimensions(),
|
dim = noteEvent.dimensions(),
|
||||||
uri = noteEvent.toNostrUri(),
|
uri = note.toNostrUri(),
|
||||||
mimeType = mimeType,
|
mimeType = mimeType,
|
||||||
encryptionAlgo = algo,
|
encryptionAlgo = algo,
|
||||||
encryptionKey = key,
|
encryptionKey = key,
|
||||||
|
@ -58,7 +58,6 @@ import com.vitorpamplona.quartz.nip01Core.tags.addressables.Address
|
|||||||
import com.vitorpamplona.quartz.nip01Core.tags.events.ETag
|
import com.vitorpamplona.quartz.nip01Core.tags.events.ETag
|
||||||
import com.vitorpamplona.quartz.nip02FollowList.EmptyTagList
|
import com.vitorpamplona.quartz.nip02FollowList.EmptyTagList
|
||||||
import com.vitorpamplona.quartz.nip10Notes.BaseThreadedEvent
|
import com.vitorpamplona.quartz.nip10Notes.BaseThreadedEvent
|
||||||
import com.vitorpamplona.quartz.nip19Bech32.toNIP19
|
|
||||||
import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent
|
import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
@ -260,7 +259,7 @@ fun DisplayEntryForNote(
|
|||||||
style = LocalTextStyle.current.copy(color = MaterialTheme.colorScheme.primary),
|
style = LocalTextStyle.current.copy(color = MaterialTheme.colorScheme.primary),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
DisplayEvent(noteEvent.id, noteEvent.kind, noteEvent.toNIP19(), null, accountViewModel, nav)
|
DisplayEvent(noteEvent.id, noteEvent.kind, note.toNostrUri(), null, accountViewModel, nav)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,6 @@ import com.vitorpamplona.quartz.nip10Notes.content.findHashtags
|
|||||||
import com.vitorpamplona.quartz.nip10Notes.content.findNostrUris
|
import com.vitorpamplona.quartz.nip10Notes.content.findNostrUris
|
||||||
import com.vitorpamplona.quartz.nip10Notes.content.findURLs
|
import com.vitorpamplona.quartz.nip10Notes.content.findURLs
|
||||||
import com.vitorpamplona.quartz.nip18Reposts.quotes.quotes
|
import com.vitorpamplona.quartz.nip18Reposts.quotes.quotes
|
||||||
import com.vitorpamplona.quartz.nip21UriScheme.toNostrUri
|
|
||||||
import com.vitorpamplona.quartz.nip28PublicChat.base.notify
|
import com.vitorpamplona.quartz.nip28PublicChat.base.notify
|
||||||
import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent
|
import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent
|
||||||
import com.vitorpamplona.quartz.nip30CustomEmoji.emojis
|
import com.vitorpamplona.quartz.nip30CustomEmoji.emojis
|
||||||
@ -878,7 +877,7 @@ fun ShowVideoStreaming(
|
|||||||
description = baseChannel.toBestDisplayName(),
|
description = baseChannel.toBestDisplayName(),
|
||||||
artworkUri = event.image(),
|
artworkUri = event.image(),
|
||||||
authorName = baseChannel.creatorName(),
|
authorName = baseChannel.creatorName(),
|
||||||
uri = event.toNostrUri(),
|
uri = baseChannel.toNAddr(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,6 +127,7 @@ import com.vitorpamplona.amethyst.ui.note.types.FileStorageHeaderDisplay
|
|||||||
import com.vitorpamplona.amethyst.ui.note.types.PictureDisplay
|
import com.vitorpamplona.amethyst.ui.note.types.PictureDisplay
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.RenderAppDefinition
|
import com.vitorpamplona.amethyst.ui.note.types.RenderAppDefinition
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.RenderChannelMessage
|
import com.vitorpamplona.amethyst.ui.note.types.RenderChannelMessage
|
||||||
|
import com.vitorpamplona.amethyst.ui.note.types.RenderChatMessageEncryptedFile
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.RenderEmojiPack
|
import com.vitorpamplona.amethyst.ui.note.types.RenderEmojiPack
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.RenderFhirResource
|
import com.vitorpamplona.amethyst.ui.note.types.RenderFhirResource
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.RenderGitIssueEvent
|
import com.vitorpamplona.amethyst.ui.note.types.RenderGitIssueEvent
|
||||||
@ -177,6 +178,7 @@ import com.vitorpamplona.quartz.nip01Core.tags.addressables.isTaggedAddressableK
|
|||||||
import com.vitorpamplona.quartz.nip01Core.tags.geohash.getGeoHash
|
import com.vitorpamplona.quartz.nip01Core.tags.geohash.getGeoHash
|
||||||
import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent
|
import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent
|
||||||
import com.vitorpamplona.quartz.nip13Pow.strongPoWOrNull
|
import com.vitorpamplona.quartz.nip13Pow.strongPoWOrNull
|
||||||
|
import com.vitorpamplona.quartz.nip17Dm.files.ChatMessageEncryptedFileHeaderEvent
|
||||||
import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent
|
import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent
|
import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent
|
||||||
import com.vitorpamplona.quartz.nip18Reposts.RepostEvent
|
import com.vitorpamplona.quartz.nip18Reposts.RepostEvent
|
||||||
@ -564,6 +566,17 @@ private fun FullBleedNoteCompose(
|
|||||||
)
|
)
|
||||||
} else if (noteEvent is ChatMessageRelayListEvent) {
|
} else if (noteEvent is ChatMessageRelayListEvent) {
|
||||||
DisplayDMRelayList(baseNote, backgroundColor, accountViewModel, nav)
|
DisplayDMRelayList(baseNote, backgroundColor, accountViewModel, nav)
|
||||||
|
} else if (noteEvent is ChatMessageEncryptedFileHeaderEvent) {
|
||||||
|
RenderChatMessageEncryptedFile(
|
||||||
|
baseNote,
|
||||||
|
false,
|
||||||
|
canPreview,
|
||||||
|
3,
|
||||||
|
backgroundColor,
|
||||||
|
editState,
|
||||||
|
accountViewModel,
|
||||||
|
nav,
|
||||||
|
)
|
||||||
} else if (noteEvent is AdvertisedRelayListEvent) {
|
} else if (noteEvent is AdvertisedRelayListEvent) {
|
||||||
DisplayNIP65RelayList(baseNote, backgroundColor, accountViewModel, nav)
|
DisplayNIP65RelayList(baseNote, backgroundColor, accountViewModel, nav)
|
||||||
} else if (noteEvent is SearchRelayListEvent) {
|
} else if (noteEvent is SearchRelayListEvent) {
|
||||||
|
@ -25,9 +25,9 @@ import com.vitorpamplona.quartz.nip01Core.core.Event
|
|||||||
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
|
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
|
||||||
import com.vitorpamplona.quartz.nip19Bech32.entities.NEvent
|
import com.vitorpamplona.quartz.nip19Bech32.entities.NEvent
|
||||||
|
|
||||||
fun Event.toNIP19(): String =
|
fun Event.toNIP19(relayHint: String? = null): String =
|
||||||
if (this is AddressableEvent) {
|
if (this is AddressableEvent) {
|
||||||
ATag(kind, pubKey, dTag(), null).toNAddr()
|
ATag(kind, pubKey, dTag(), relayHint).toNAddr()
|
||||||
} else {
|
} else {
|
||||||
NEvent.create(id, pubKey, kind, null)
|
NEvent.create(id, pubKey, kind, relayHint)
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,6 @@ import com.vitorpamplona.quartz.nip01Core.core.Event
|
|||||||
import com.vitorpamplona.quartz.nip01Core.hints.EventHintBundle
|
import com.vitorpamplona.quartz.nip01Core.hints.EventHintBundle
|
||||||
import com.vitorpamplona.quartz.nip19Bech32.toNIP19
|
import com.vitorpamplona.quartz.nip19Bech32.toNIP19
|
||||||
|
|
||||||
fun Event.toNostrUri(): String = "nostr:${toNIP19()}"
|
fun Event.toNostrUri(relayHint: String? = null): String = "nostr:${toNIP19(relayHint)}"
|
||||||
|
|
||||||
fun EventHintBundle<Event>.toNostrUri(): String = "nostr:${toNEvent()}"
|
fun EventHintBundle<Event>.toNostrUri(): String = "nostr:${toNEvent()}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user