Fix: Mejorar manejo de duracion de audio y errores de envio
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m10s
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m10s
- Validar que duration sea numero finito en MessageAudio - Obtener duracion del elemento audio si no esta en metadata - Agregar toast de error para envio de notas de voz
This commit is contained in:
@@ -104,7 +104,12 @@ const isPlaying = ref(false)
|
||||
const loading = ref(true)
|
||||
const error = ref(false)
|
||||
const currentTime = ref(0)
|
||||
const duration = ref(props.media.duration || 0)
|
||||
// Ensure duration is a valid number
|
||||
const duration = ref(
|
||||
typeof props.media.duration === 'number' && isFinite(props.media.duration) && props.media.duration > 0
|
||||
? props.media.duration
|
||||
: 0
|
||||
)
|
||||
|
||||
const audioUrl = computed(() => {
|
||||
if (props.media.url) return props.media.url
|
||||
@@ -155,8 +160,12 @@ const seekTo = (e: MouseEvent) => {
|
||||
|
||||
const onLoadedMetadata = () => {
|
||||
loading.value = false
|
||||
if (audioRef.value && !props.media.duration) {
|
||||
duration.value = audioRef.value.duration
|
||||
// Always try to get duration from audio element if we don't have a valid one
|
||||
if (audioRef.value) {
|
||||
const audioDuration = audioRef.value.duration
|
||||
if (isFinite(audioDuration) && audioDuration > 0 && duration.value === 0) {
|
||||
duration.value = audioDuration
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -587,8 +587,22 @@ const handleSendVoice = async (audioFile: File) => {
|
||||
|
||||
// Reload messages
|
||||
messages.value = await $fetch(`/api/messages/${instanceId}/${chatId}`)
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
console.error('Error sending voice message:', e)
|
||||
|
||||
let errorMessage = 'Error al enviar la nota de voz'
|
||||
if (e?.data?.message) {
|
||||
errorMessage = e.data.message
|
||||
} else if (e?.message) {
|
||||
errorMessage = e.message
|
||||
}
|
||||
|
||||
toast.add({
|
||||
title: 'Error de envío',
|
||||
description: errorMessage,
|
||||
color: 'error',
|
||||
duration: 5000
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user