code review:

added p-tag for voice reply to kind 1
allow waveform IMeta with a missing mimeType to render as audio
This commit is contained in:
davotoula
2026-01-11 17:39:08 +01:00
parent 70c638ad90
commit f51d0fb56e
5 changed files with 31 additions and 15 deletions
@@ -68,13 +68,6 @@ fun RenderTextEvent(
) {
val noteEvent = note.event ?: return
// Check if this is an audio-only event (content is just an audio URL with waveform IMeta)
val isAudioOnly = remember(noteEvent) { noteEvent.isAudioOnlyContent() }
if (isAudioOnly) {
RenderAudioFromIMeta(note, accountViewModel, nav)
return
}
val showReply by
remember(note) {
derivedStateOf {
@@ -107,6 +100,13 @@ fun RenderTextEvent(
}
}
// Check if this is an audio-only event (content is just an audio URL with waveform IMeta)
val isAudioOnly = remember(noteEvent) { noteEvent.isAudioOnlyContent() }
if (isAudioOnly) {
RenderAudioFromIMeta(note, accountViewModel, nav)
return
}
LoadDecryptedContent(
note,
accountViewModel,
@@ -301,7 +301,7 @@ fun Event.getAudioMetaWithWaveform(): AudioMeta? {
val audioMetas = imetas().map { AudioMeta.parse(it) }
return audioMetas.firstOrNull { meta ->
meta.waveform != null &&
meta.mimeType?.startsWith("audio/") == true
meta.mimeType?.startsWith("audio/") != false
}
}
@@ -105,10 +105,12 @@ import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal
import com.vitorpamplona.quartz.nip01Core.signers.SignerExceptions
import com.vitorpamplona.quartz.nip01Core.tags.people.PubKeyReferenceTag
import com.vitorpamplona.quartz.nip01Core.tags.people.isTaggedUser
import com.vitorpamplona.quartz.nip01Core.tags.people.toPTag
import com.vitorpamplona.quartz.nip03Timestamp.EmptyOtsResolverBuilder
import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent
import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent
import com.vitorpamplona.quartz.nip10Notes.tags.markedETags
import com.vitorpamplona.quartz.nip10Notes.tags.notify
import com.vitorpamplona.quartz.nip10Notes.tags.prepareETagsAsReplyTo
import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKeyable
import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent
@@ -394,7 +396,7 @@ class AccountViewModel(
note.flow().author(),
note.flow().metadata.stateFlow,
note.flow().reports.stateFlow,
) { hiddenUsers, followingUsers, autor, metadata, reports ->
) { hiddenUsers, followingUsers, _, metadata, _ ->
emit(isNoteAcceptable(metadata.note, hiddenUsers, followingUsers.authors))
}.onStart {
emit(
@@ -1015,11 +1017,11 @@ class AccountViewModel(
LocalCache.findLatestModificationForNote(note)
}
fun checkGetOrCreatePublicChatChannel(key: HexKey): PublicChatChannel? = LocalCache.getOrCreatePublicChatChannel(key)
fun checkGetOrCreatePublicChatChannel(key: HexKey): PublicChatChannel = LocalCache.getOrCreatePublicChatChannel(key)
fun checkGetOrCreateLiveActivityChannel(key: Address): LiveActivitiesChannel? = LocalCache.getOrCreateLiveChannel(key)
fun checkGetOrCreateLiveActivityChannel(key: Address): LiveActivitiesChannel = LocalCache.getOrCreateLiveChannel(key)
fun checkGetOrCreateEphemeralChatChannel(key: RoomId): EphemeralChatChannel? = LocalCache.getOrCreateEphemeralChannel(key)
fun checkGetOrCreateEphemeralChatChannel(key: RoomId): EphemeralChatChannel = LocalCache.getOrCreateEphemeralChannel(key)
fun getPublicChatChannelIfExists(hex: HexKey) = LocalCache.getPublicChatChannelIfExists(hex)
@@ -1202,6 +1204,7 @@ class AccountViewModel(
if (replyingTo != null) {
val tags = prepareETagsAsReplyTo(replyingTo, null)
markedETags(tags)
notify(replyingTo.toPTag())
}
// Add audio as IMeta attachment
add(audioMeta.toIMetaArray())
@@ -1451,7 +1454,7 @@ class AccountViewModel(
// First check if we have an actual response from the DVM in LocalCache
val response =
LocalCache.notes.maxOrNullOf(
filter = { key, note ->
filter = { _, note ->
val noteEvent = note.event
noteEvent is NIP90ContentDiscoveryResponseEvent &&
noteEvent.pubKey == pubkeyHex &&
@@ -1560,8 +1563,6 @@ class AccountViewModel(
}
}
fun findUsersStartingWithSync(prefix: String) = LocalCache.findUsersStartingWith(prefix, account)
fun convertAccounts(loggedInAccounts: List<AccountInfo>?): Set<HexKey> =
loggedInAccounts
?.mapNotNull {
@@ -582,6 +582,18 @@ open class ShortNotePostViewModel :
}
markedETags(tags)
}
pTags?.let { userList ->
val tags =
userList.map {
val tag = it.toPTag()
if (tag.relayHint == null) {
tag.copy(relayHint = LocalCache.relayHints.hintsForKey(it.pubkeyHex).firstOrNull())
} else {
tag
}
}
notify(tags)
}
// Add audio as IMeta attachment
add(audioMeta.toIMetaArray())
}
@@ -38,8 +38,10 @@ import com.vitorpamplona.amethyst.ui.actions.uploads.RecordingResult
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
import com.vitorpamplona.amethyst.ui.stringRes
import com.vitorpamplona.quartz.nip01Core.core.Event
import com.vitorpamplona.quartz.nip01Core.tags.people.toPTag
import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent
import com.vitorpamplona.quartz.nip10Notes.tags.markedETags
import com.vitorpamplona.quartz.nip10Notes.tags.notify
import com.vitorpamplona.quartz.nip10Notes.tags.prepareETagsAsReplyTo
import com.vitorpamplona.quartz.nipA0VoiceMessages.AudioMeta
import com.vitorpamplona.quartz.nipA0VoiceMessages.BaseVoiceEvent
@@ -232,6 +234,7 @@ class VoiceReplyViewModel : ViewModel() {
if (replyingTo != null) {
val tags = prepareETagsAsReplyTo(replyingTo, null)
markedETags(tags)
notify(replyingTo.toPTag())
}
// Add audio as IMeta attachment
add(audioMeta.toIMetaArray())