Update conversations.php
This commit is contained in:
+41
-4
@@ -873,6 +873,9 @@
|
||||
<button class="btn" id="send-btn">
|
||||
<i class="fas fa-paper-plane"></i>
|
||||
</button>
|
||||
<button class="btn btn-danger" id="delete-file-btn" title="Eliminar" style="display:none; margin-left:6px;">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1344,8 +1347,9 @@
|
||||
try { self.initRecordingHandlers(); } catch(e) { console.warn('initRecordingHandlers failed', e); }
|
||||
}
|
||||
|
||||
// While recording: clicking mic cancels the recording (as requested)
|
||||
if (self._mediaRecorder && self._mediaRecorder.state === 'recording') {
|
||||
try { self.stopRecording(); } catch (e) { console.warn('stopRecording failed', e); }
|
||||
try { self.cancelRecording(); } catch (e) { console.warn('cancelRecording failed', e); }
|
||||
} else {
|
||||
try { self.startRecording(); } catch (e) { console.warn('startRecording failed', e); alert('No se pudo iniciar la grabación.'); }
|
||||
}
|
||||
@@ -2430,12 +2434,30 @@
|
||||
// set as selected file and show preview
|
||||
this.selectedFile = file;
|
||||
this.showMediaPreview(file);
|
||||
// restore mic UI to default (not recording)
|
||||
try {
|
||||
const micEl2 = document.getElementById('mic-btn');
|
||||
if (micEl2) {
|
||||
micEl2.innerHTML = micEl2.dataset._wa_prev || '<i class="fas fa-microphone"></i>';
|
||||
micEl2.title = 'Grabar audio';
|
||||
micEl2.classList.remove('recording-cancel');
|
||||
}
|
||||
} catch(e) { /* ignore */ }
|
||||
// Clear recorder reference to indicate stopped
|
||||
this._mediaRecorder = null;
|
||||
};
|
||||
|
||||
this._mediaRecorder.start();
|
||||
this._recordingStart = Date.now();
|
||||
const ind = document.getElementById('recording-indicator'); if (ind) ind.style.display = 'block';
|
||||
const micEl = document.getElementById('mic-btn'); if (micEl) micEl.classList.add('recording');
|
||||
const micEl = document.getElementById('mic-btn'); if (micEl) {
|
||||
// Show cancel on same button
|
||||
micEl.dataset._wa_prev = micEl.innerHTML;
|
||||
micEl.innerHTML = '<i class="fas fa-times"></i>';
|
||||
micEl.title = 'Cancelar';
|
||||
micEl.classList.add('recording');
|
||||
micEl.classList.add('recording-cancel');
|
||||
}
|
||||
// Ensure UI shows mic and hides send while recording
|
||||
if (this._updateSendMicVisibility) this._updateSendMicVisibility();
|
||||
const update = () => {
|
||||
@@ -2474,7 +2496,14 @@
|
||||
this._recordingInterval = null;
|
||||
this._recordingStart = null;
|
||||
const ind = document.getElementById('recording-indicator'); if (ind) ind.style.display = 'none';
|
||||
const micEl = document.getElementById('mic-btn'); if (micEl) micEl.classList.remove('recording');
|
||||
const micEl = document.getElementById('mic-btn'); if (micEl) {
|
||||
micEl.classList.remove('recording');
|
||||
micEl.classList.remove('recording-cancel');
|
||||
micEl.innerHTML = micEl.dataset._wa_prev || '<i class="fas fa-microphone"></i>';
|
||||
micEl.title = 'Grabar audio';
|
||||
}
|
||||
// hide delete button if present
|
||||
const delBtn = document.getElementById('delete-file-btn'); if (delBtn) delBtn.style.display = 'none';
|
||||
if (this._updateSendMicVisibility) this._updateSendMicVisibility();
|
||||
};
|
||||
|
||||
@@ -2960,6 +2989,13 @@
|
||||
// Mostrar preview
|
||||
preview.style.display = 'block';
|
||||
|
||||
// Show delete button next to send
|
||||
const delBtn = document.getElementById('delete-file-btn');
|
||||
if (delBtn) {
|
||||
delBtn.style.display = 'inline-flex';
|
||||
delBtn.onclick = () => { this.cancelMediaUpload(); };
|
||||
}
|
||||
|
||||
// Use the main send handler: `sendMessage` will delegate to media send when a file is selected
|
||||
const sendBtn = document.getElementById('send-btn');
|
||||
// ensure send button is enabled
|
||||
@@ -3065,7 +3101,8 @@
|
||||
|
||||
// Restaurar botón enviar
|
||||
const sendBtn = document.getElementById('send-btn');
|
||||
sendBtn.onclick = null;
|
||||
if (sendBtn) { sendBtn.onclick = null; sendBtn.disabled = false; sendBtn.innerHTML = '<i class="fas fa-paper-plane"></i>'; }
|
||||
const delBtn = document.getElementById('delete-file-btn'); if (delBtn) delBtn.style.display = 'none';
|
||||
}
|
||||
|
||||
renderMediaMessage(message) {
|
||||
|
||||
Reference in New Issue
Block a user