//esta funcion ocultarPreviews( es vieja porque ya no son id, ahora son clases y se…
- User
//esta funcion ocultarPreviews( es vieja porque ya no son id, ahora son clases y se procesan mediante subidaArchivosChat(chatContainer), ajusta function ocultarPreviews() { const previewChatAudio = document.getElementById('previewChatAudio'); const previewChatImagen = document.getElementById('previewChatImagen'); const previewChatArchivo = document.getElementById('previewChatArchivo'); const cancelUploadButton = document.getElementById('cancelUploadButton'); previewChatAudio.style.display = 'none'; previewChatImagen.style.display = 'none'; previewChatArchivo.style.display = 'none'; cancelUploadButton.style.display = 'none'; }
function subidaArchivosChat(chatContainer) { const enviarAdjunto = chatContainer.querySelector('.enviarAdjunto'); const previewChatArchivo = chatContainer.querySelector('.previewChatArchivo'); const previewChatAudio = chatContainer.querySelector('.previewChatAudio'); const previewChatImagen = chatContainer.querySelector('.previewChatImagen'); const cancelUploadButton = chatContainer.querySelector('.cancelUploadButton'); const elements = {enviarAdjunto, previewChatArchivo, previewChatAudio, previewChatImagen, cancelUploadButton}; const missingElements = Object.entries(elements) .filter(([_, el]) => !el) .map(([key]) => key); if (missingElements.length) { console.warn(`Missing elements in chat container: ${missingElements.join(', ')}`); return; } cancelUploadButton.addEventListener('click', () => { subidaChatProgreso = false; archivoChatId = null; archivoChatUrl = null; ocultarPreviews(); }); enviarAdjunto.addEventListener('click', () => abrirSelectorArchivos('*/*')); const inicialChatSubida = event => { event.preventDefault(); const file = event.dataTransfer?.files[0] || event.target.files[0]; if (!file) return; if (file.size > 50 * 1024 * 1024) { //console.log('El archivo no puede superar los 50 MB.'); return; } if (file.type.startsWith('audio/')) { subidaChatAudio(file); } else if (file.type.startsWith('image/')) { subidaChatImagen(file); } else { subidaChatArchivo(file); } };(resto del codigo omitido por brevedad)
- Assistant