This commit is contained in:
Lizandro Guarnizo
2026-01-24 00:47:13 -05:00
parent 7b2e17c740
commit 41b4c2fb32
5 changed files with 1035 additions and 10 deletions
+28 -8
View File
@@ -2125,7 +2125,6 @@
${reactionHtml}
<div class="message-actions mt-1">
<button class="btn btn-sm btn-link" onclick="chat.promptReply('${msg.message_id}')" title="Responder"><i class="fas fa-reply"></i></button>
<button class="btn btn-sm btn-link" onclick="chat.forwardMessage('${msg.message_id}')" title="Reenviar"><i class="fas fa-share"></i></button>
<button class="btn btn-sm btn-link" onclick="chat.openReactionPicker(event, '${msg.message_id}')" title="Reaccionar"><i class="far fa-grin"></i></button>
</div>
<div class="message-time">
@@ -2298,18 +2297,39 @@
this.scrollToBottom();
}
showReplyPreview(messageId, type = 'reply') {
async showReplyPreview(messageId, type = 'reply') {
try {
const preview = document.getElementById('reply-preview');
const previewText = document.getElementById('reply-preview-text');
const cancelBtn = document.getElementById('cancel-reply-btn');
const msg = this.conversations.find(m => m.message_id == messageId || m.id == messageId);
const text = msg ? (msg.content || msg.message_text || (msg.caption || '[Mensaje]')) : ('Mensaje ' + messageId);
if (preview && previewText) {
if (type === 'reply') previewText.textContent = 'En respuesta a: ' + (String(text).replace(/\n/g,' ')).substring(0,140);
else if (type === 'forward') previewText.textContent = 'Reenviando: ' + (String(text).replace(/\n/g,' ')).substring(0,140);
preview.style.display = 'flex';
let msg = this.conversations.find(m => m.message_id == messageId || m.id == messageId);
const setPreviewFromMsg = (m) => {
const text = m ? (m.content || m.message_text || (m.caption || '[Mensaje]')) : ('Mensaje ' + messageId);
if (preview && previewText) {
if (type === 'reply') previewText.textContent = 'En respuesta a: ' + (String(text).replace(/\n/g,' ')).substring(0,140);
else if (type === 'forward') previewText.textContent = 'Reenviando: ' + (String(text).replace(/\n/g,' ')).substring(0,140);
preview.style.display = 'flex';
}
};
if (!msg) {
// intentar obtener mensaje por API
try {
const resp = await fetch(`api/get_message.php?message_id=${encodeURIComponent(messageId)}`);
if (resp.ok) {
const j = await resp.json();
if (j && j.success && j.data) {
msg = j.data;
}
}
} catch (err) {
console.warn('Could not fetch referenced message', err);
}
}
setPreviewFromMsg(msg);
if (cancelBtn) {
cancelBtn.onclick = () => this.hideReplyPreview();
}