feat: Remove debug logging from message sending and user blocking/unblocking functions

This commit is contained in:
k1ngsterr1
2026-01-14 03:44:29 +05:00
parent 671b68103f
commit e9dece8e86
7 changed files with 3 additions and 255 deletions

View File

@@ -911,13 +911,9 @@ fun ChatDetailScreen(
}
},
onSend = {
android.util.Log.d("ChatDetailScreen", "🔥🔥🔥 onSend callback CALLED 🔥🔥🔥")
android.util.Log.d("ChatDetailScreen", "📝 inputText: '$inputText'")
// Скрываем кнопку scroll на время отправки
isSendingMessage = true
android.util.Log.d("ChatDetailScreen", "➡️ Calling viewModel.sendMessage()")
viewModel.sendMessage()
android.util.Log.d("ChatDetailScreen", "✅ viewModel.sendMessage() called")
// Скроллим к новому сообщению
scope.launch {
delay(100)
@@ -1322,9 +1318,8 @@ fun ChatDetailScreen(
account = currentUserPublicKey,
opponentKey = user.publicKey
)
android.util.Log.d("ChatDetail", "✅ Chat deleted with: ${user.publicKey.take(10)}")
} catch (e: Exception) {
android.util.Log.e("ChatDetail", " Error deleting chat", e)
// Error deleting chat
}
// Выходим ПОСЛЕ удаления
onBack()
@@ -1366,7 +1361,6 @@ fun ChatDetailScreen(
showBlockConfirm = false
scope.launch {
try {
android.util.Log.d("ChatDetail", "🚫 Blocking user: ${user.publicKey.take(10)}")
// Добавляем пользователя в blacklist
database.blacklistDao().blockUser(
com.rosetta.messenger.database.BlacklistEntity(
@@ -1375,9 +1369,8 @@ fun ChatDetailScreen(
)
)
isBlocked = true
android.util.Log.d("ChatDetail", "✅ User blocked: ${user.publicKey.take(10)}")
} catch (e: Exception) {
android.util.Log.e("ChatDetail", " Error blocking user", e)
// Error blocking user
}
}
}
@@ -1417,16 +1410,14 @@ fun ChatDetailScreen(
showUnblockConfirm = false
scope.launch {
try {
android.util.Log.d("ChatDetail", "✅ Unblocking user: ${user.publicKey.take(10)}")
// Удаляем пользователя из blacklist
database.blacklistDao().unblockUser(
publicKey = user.publicKey,
account = currentUserPublicKey
)
isBlocked = false
android.util.Log.d("ChatDetail", "✅ User unblocked: ${user.publicKey.take(10)}")
} catch (e: Exception) {
android.util.Log.e("ChatDetail", " Error unblocking user", e)
// Error unblocking user
}
}
}
@@ -2087,10 +2078,8 @@ private fun MessageInputBar(
// Функция отправки - НЕ закрывает клавиатуру (UX правило #6)
fun handleSend() {
android.util.Log.d("MessageInputBar", "🚀 handleSend() called, value='$value', isNotBlank=${value.isNotBlank()}, hasReply=$hasReply")
// Можно отправить если есть текст ИЛИ есть reply (как в React Native)
if (value.isNotBlank() || hasReply) {
android.util.Log.d("MessageInputBar", "✅ Calling onSend()")
onSend()
// Очищаем инпут, но клавиатура остаётся открытой
}

View File

@@ -839,7 +839,6 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
* - Поддержка Reply/Forward через attachments (как в React Native)
*/
fun sendMessage() {
android.util.Log.e("REPLY_DEBUG", "🚀🚀🚀 sendMessage() CALLED 🚀🚀🚀")
Log.d(TAG, "🚀🚀🚀 sendMessage() CALLED 🚀🚀🚀")
val text = _inputText.value.trim()
@@ -849,7 +848,6 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
val replyMsgs = _replyMessages.value
val isForward = _isForwardMode.value
android.util.Log.e("REPLY_DEBUG", "📝 Text: '$text', ReplyMsgs: ${replyMsgs.size}")
Log.d(TAG, "📝 Text: '$text'")
Log.d(TAG, "📧 Recipient: ${recipient?.take(16)}")
Log.d(TAG, "👤 Sender: ${sender?.take(16)}")
@@ -932,7 +930,6 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
var replyBlobPlaintext = "" // Сохраняем plaintext для БД
if (replyMsgsToSend.isNotEmpty()) {
android.util.Log.e("REPLY_DEBUG", "🔥 FORMING REPLY ATTACHMENT, count=${replyMsgsToSend.size}")
// Формируем JSON массив с цитируемыми сообщениями (как в RN)
val replyJsonArray = JSONArray()
@@ -945,17 +942,12 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
put("attachments", JSONArray()) // Пустой массив вложений
}
replyJsonArray.put(replyJson)
android.util.Log.e("REPLY_DEBUG", " - Reply msg: id=${msg.messageId}, text='${msg.text.take(30)}'")
}
replyBlobPlaintext = replyJsonArray.toString() // 🔥 Сохраняем plaintext
android.util.Log.e("REPLY_DEBUG", " - Reply blob plaintext length: ${replyBlobPlaintext.length}")
android.util.Log.e("REPLY_DEBUG", " - Reply blob plaintext: ${replyBlobPlaintext.take(100)}")
// 🔥 Шифруем reply blob plainKeyAndNonce (как в React Native)
val encryptedReplyBlob = MessageCrypto.encryptReplyBlob(replyBlobPlaintext, plainKeyAndNonce)
android.util.Log.e("REPLY_DEBUG", " - Encrypted reply blob length: ${encryptedReplyBlob.length}")
android.util.Log.e("REPLY_DEBUG", " - Encrypted reply blob: ${encryptedReplyBlob.take(60)}")
val replyAttachmentId = "reply_${timestamp}"
messageAttachments.add(MessageAttachment(
@@ -964,7 +956,6 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
type = AttachmentType.MESSAGES,
preview = ""
))
android.util.Log.e("REPLY_DEBUG", " ✅ Reply attachment added, id=$replyAttachmentId")
}
val packet = PacketMessage().apply {
@@ -983,19 +974,13 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
Log.d(TAG, " - messageId: $messageId")
Log.d(TAG, " - text: '$text'")
Log.d(TAG, " - attachments count: ${packet.attachments.size}")
android.util.Log.e("REPLY_DEBUG", "📦 PACKET READY TO SEND:")
android.util.Log.e("REPLY_DEBUG", " - messageId: $messageId")
android.util.Log.e("REPLY_DEBUG", " - text: '$text'")
android.util.Log.e("REPLY_DEBUG", " - attachments count: ${packet.attachments.size}")
packet.attachments.forEach { att ->
Log.d(TAG, " - attachment: type=${att.type}, id=${att.id}, blob.length=${att.blob.length}")
android.util.Log.e("REPLY_DEBUG", " - attachment: type=${att.type}, id=${att.id}, blob.length=${att.blob.length}")
}
// Отправляем пакет
ProtocolManager.send(packet)
Log.d(TAG, "✅ PACKET SENT via ProtocolManager.send()")
android.util.Log.e("REPLY_DEBUG", "✅ PACKET SENT via ProtocolManager.send()")
// 3. 🎯 UI обновление в Main потоке
withContext(Dispatchers.Main) {

View File

@@ -55,19 +55,16 @@ class ChatsListViewModel(application: Application) : AndroidViewModel(applicatio
*/
fun setAccount(publicKey: String, privateKey: String) {
if (currentAccount == publicKey) {
android.util.Log.d("ChatsListViewModel", "⚠️ setAccount called again for same account, skipping")
return
}
currentAccount = publicKey
currentPrivateKey = privateKey
android.util.Log.d("ChatsListViewModel", "✅ Setting up dialogs Flow for account: ${publicKey.take(16)}...")
viewModelScope.launch {
dialogDao.getDialogsFlow(publicKey)
.flowOn(Dispatchers.IO) // 🚀 Flow работает на IO
.map { dialogsList ->
android.util.Log.d("ChatsListViewModel", "📋 Dialogs Flow emitted: ${dialogsList.size} dialogs")
// 🔓 Расшифровываем lastMessage на IO потоке (PBKDF2 - тяжелая операция!)
dialogsList.map { dialog ->
val decryptedLastMessage = try {
@@ -99,7 +96,6 @@ class ChatsListViewModel(application: Application) : AndroidViewModel(applicatio
.flowOn(Dispatchers.Default) // 🚀 map выполняется на Default (CPU)
.flowOn(Dispatchers.Main) // 🎯 КРИТИЧНО: Обновляем UI на главном потоке!
.collect { decryptedDialogs ->
android.util.Log.d("ChatsListViewModel", "✅ Updated UI with ${decryptedDialogs.size} decrypted dialogs")
_dialogs.value = decryptedDialogs
// 🟢 Подписываемся на онлайн-статусы всех собеседников
@@ -156,9 +152,7 @@ class ChatsListViewModel(application: Application) : AndroidViewModel(applicatio
dialogDao.updateOpponentInfo(currentAccount, opponentKey, opponentTitle, opponentUsername, verified)
}
android.util.Log.d("ChatsListViewModel", "✅ Dialog upserted from messages table")
} catch (e: Exception) {
android.util.Log.e("ChatsListViewModel", "Error upserting dialog", e)
}
}