feat: Add detailed logging for message sending process in ChatViewModel and MessageInputBar

This commit is contained in:
k1ngsterr1
2026-01-13 03:40:50 +05:00
parent 62093e1b1e
commit 40fbbabdee
2 changed files with 28 additions and 1 deletions

View File

@@ -936,9 +936,13 @@ fun ChatDetailScreen(
} }
}, },
onSend = { onSend = {
android.util.Log.d("ChatDetailScreen", "🔥🔥🔥 onSend callback CALLED 🔥🔥🔥")
android.util.Log.d("ChatDetailScreen", "📝 inputText: '$inputText'")
// Скрываем кнопку scroll на время отправки // Скрываем кнопку scroll на время отправки
isSendingMessage = true isSendingMessage = true
android.util.Log.d("ChatDetailScreen", "➡️ Calling viewModel.sendMessage()")
viewModel.sendMessage() viewModel.sendMessage()
android.util.Log.d("ChatDetailScreen", "✅ viewModel.sendMessage() called")
// Скроллим к новому сообщению // Скроллим к новому сообщению
scope.launch { scope.launch {
delay(100) delay(100)
@@ -1625,7 +1629,9 @@ private fun MessageInputBar(
// Функция отправки - НЕ закрывает клавиатуру (UX правило #6) // Функция отправки - НЕ закрывает клавиатуру (UX правило #6)
fun handleSend() { fun handleSend() {
android.util.Log.d("MessageInputBar", "🚀 handleSend() called, value='$value', isNotBlank=${value.isNotBlank()}")
if (value.isNotBlank()) { if (value.isNotBlank()) {
android.util.Log.d("MessageInputBar", "✅ Calling onSend()")
onSend() onSend()
// Очищаем инпут, но клавиатура остаётся открытой // Очищаем инпут, но клавиатура остаётся открытой
} }

View File

@@ -489,6 +489,9 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
* - Поддержка Reply/Forward * - Поддержка Reply/Forward
*/ */
fun sendMessage() { fun sendMessage() {
Log.d(TAG, "🚀🚀🚀 sendMessage() CALLED 🚀🚀🚀")
ProtocolManager.addLog("🚀🚀🚀 sendMessage() CALLED")
val text = _inputText.value.trim() val text = _inputText.value.trim()
val recipient = opponentKey val recipient = opponentKey
val sender = myPublicKey val sender = myPublicKey
@@ -496,24 +499,42 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
val replyMsgs = _replyMessages.value val replyMsgs = _replyMessages.value
val isForward = _isForwardMode.value val isForward = _isForwardMode.value
Log.d(TAG, "📝 Text: '$text'")
Log.d(TAG, "📧 Recipient: ${recipient?.take(16)}")
Log.d(TAG, "👤 Sender: ${sender?.take(16)}")
Log.d(TAG, "🔑 PrivateKey exists: ${privateKey != null}")
Log.d(TAG, "💬 ReplyMsgs: ${replyMsgs.size}")
ProtocolManager.addLog("📝 Text: '$text'")
ProtocolManager.addLog("📧 Recipient: ${recipient?.take(16)}")
ProtocolManager.addLog("👤 Sender: ${sender?.take(16)}")
ProtocolManager.addLog("🔑 PrivateKey exists: ${privateKey != null}")
// Разрешаем отправку пустого текста если есть reply/forward // Разрешаем отправку пустого текста если есть reply/forward
if (text.isEmpty() && replyMsgs.isEmpty()) { if (text.isEmpty() && replyMsgs.isEmpty()) {
ProtocolManager.addLog("❌ Empty text") Log.e(TAG, "❌ Empty text and no reply")
ProtocolManager.addLog("❌ Empty text and no reply")
return return
} }
if (recipient == null) { if (recipient == null) {
Log.e(TAG, "❌ No recipient")
ProtocolManager.addLog("❌ No recipient") ProtocolManager.addLog("❌ No recipient")
return return
} }
if (sender == null || privateKey == null) { if (sender == null || privateKey == null) {
Log.e(TAG, "❌ No keys - sender: $sender, privateKey: $privateKey")
ProtocolManager.addLog("❌ No keys - set via setUserKeys()") ProtocolManager.addLog("❌ No keys - set via setUserKeys()")
return return
} }
if (isSending) { if (isSending) {
Log.w(TAG, "⏳ Already sending...")
ProtocolManager.addLog("⏳ Already sending...") ProtocolManager.addLog("⏳ Already sending...")
return return
} }
Log.d(TAG, "✅ All checks passed, starting send...")
ProtocolManager.addLog("✅ All checks passed, starting send...")
isSending = true isSending = true
val messageId = UUID.randomUUID().toString().replace("-", "").take(32) val messageId = UUID.randomUUID().toString().replace("-", "").take(32)