Merge pull request #3984 from vector-im/feature/ons/fix_voice_message_rendering
Fix rendering voice message if the waveform data is corrupted
This commit is contained in:
commit
88bb845910
|
@ -0,0 +1 @@
|
|||
Voice Message - Cannot render voice message if the waveform data is corrupted
|
|
@ -32,5 +32,5 @@ data class AudioWaveformInfo(
|
|||
* List of integers between zero and 1024, inclusive.
|
||||
*/
|
||||
@Json(name = "waveform")
|
||||
val waveform: List<Int>? = null
|
||||
val waveform: List<Int?>? = null
|
||||
)
|
||||
|
|
|
@ -185,7 +185,7 @@ internal class DefaultSendService @AssistedInject constructor(
|
|||
name = messageContent.body,
|
||||
queryUri = Uri.parse(messageContent.url),
|
||||
type = ContentAttachmentData.Type.AUDIO,
|
||||
waveform = messageContent.audioWaveformInfo?.waveform
|
||||
waveform = messageContent.audioWaveformInfo?.waveform?.filterNotNull()
|
||||
)
|
||||
localEchoRepository.updateSendState(localEcho.eventId, roomId, SendState.UNSENT)
|
||||
internalSendMedia(listOf(localEcho.root), attachmentData, true)
|
||||
|
|
|
@ -622,11 +622,13 @@ class MessageItemFactory @Inject constructor(
|
|||
.highlighted(highlight)
|
||||
}
|
||||
|
||||
private fun List<Int>?.toFft(): List<Int>? {
|
||||
return this?.map {
|
||||
// Value comes from AudioRecordView.maxReportableAmp, and 1024 is the max value in the Matrix spec
|
||||
it * 22760 / 1024
|
||||
}
|
||||
private fun List<Int?>?.toFft(): List<Int>? {
|
||||
return this
|
||||
?.filterNotNull()
|
||||
?.map {
|
||||
// Value comes from AudioRecordView.maxReportableAmp, and 1024 is the max value in the Matrix spec
|
||||
it * 22760 / 1024
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
Loading…
Reference in New Issue