diff --git a/blueprints/messages/message_routes.py b/blueprints/messages/message_routes.py index ef76001..7fef6c9 100644 --- a/blueprints/messages/message_routes.py +++ b/blueprints/messages/message_routes.py @@ -183,8 +183,6 @@ def get_messages(conv_id): @member_required def send_message(conv_id): """Send a message to a conversation.""" - import logging - logging.getLogger(__name__).info(f"[MSG-DEBUG] send_message called: conv={conv_id}, user={current_user.id}, method={request.method}") db = SessionLocal() try: # Verify membership diff --git a/static/js/conversations.js b/static/js/conversations.js index f81c6d1..d858e6f 100644 --- a/static/js/conversations.js +++ b/static/js/conversations.js @@ -1211,7 +1211,6 @@ if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); e.stopImmediatePropagation(); - console.log('[MSG-DEBUG] Enter keydown captured, _isSending=' + state._isSending + ', _lastSendTime=' + state._lastSendTime); Composer.send(); } }, true); @@ -1225,7 +1224,6 @@ var sendBtn = document.getElementById('sendBtn'); if (sendBtn) { sendBtn.addEventListener('click', function () { - console.log('[MSG-DEBUG] Send BUTTON clicked'); Composer.send(); }); } @@ -1259,12 +1257,10 @@ // Double-send guard: flag + timestamp debounce (500ms) var now = Date.now(); if (state._isSending || (state._lastSendTime && now - state._lastSendTime < 500)) { - console.log('[MSG-DEBUG] send() BLOCKED: _isSending=' + state._isSending + ', timeSinceLast=' + (now - (state._lastSendTime || 0)) + 'ms'); return; } state._isSending = true; state._lastSendTime = now; - console.log('[MSG-DEBUG] send() EXECUTING at ' + now); var html = state.quill.root.innerHTML; var text = state.quill.getText().trim(); @@ -1294,8 +1290,10 @@ if (replyPreview) replyPreview.style.display = 'none'; Composer.renderAttachments(); - // Append the sent message + // Append the sent message and track it so polling doesn't duplicate ChatView.appendMessage(result); + if (!state.messages[convId]) state.messages[convId] = []; + state.messages[convId].push(result); // Update conversation in list ConversationList.updateConversation(convId, {