feat: Add debug logging to sendMessage function in ChatViewModel

This commit is contained in:
k1ngsterr1
2026-01-14 00:57:43 +05:00
parent 76099f7603
commit 629d4864b1
4 changed files with 23 additions and 8 deletions

View File

@@ -1946,8 +1946,8 @@ private fun MessageInputBar(
// Высота панели эмодзи = сохранённая высота клавиатуры // Высота панели эмодзи = сохранённая высота клавиатуры
val emojiPanelHeight = savedKeyboardHeight val emojiPanelHeight = savedKeyboardHeight
// Состояние отправки // Состояние отправки - можно отправить если есть текст ИЛИ есть reply
val canSend = remember(value) { value.isNotBlank() } val canSend = remember(value, hasReply) { value.isNotBlank() || hasReply }
// 🔥 Закрываем эмодзи панель когда клавиатура открывается // 🔥 Закрываем эмодзи панель когда клавиатура открывается
LaunchedEffect(isKeyboardVisible) { LaunchedEffect(isKeyboardVisible) {
@@ -1990,8 +1990,9 @@ private fun MessageInputBar(
// Функция отправки - НЕ закрывает клавиатуру (UX правило #6) // Функция отправки - НЕ закрывает клавиатуру (UX правило #6)
fun handleSend() { fun handleSend() {
android.util.Log.d("MessageInputBar", "🚀 handleSend() called, value='$value', isNotBlank=${value.isNotBlank()}") android.util.Log.d("MessageInputBar", "🚀 handleSend() called, value='$value', isNotBlank=${value.isNotBlank()}, hasReply=$hasReply")
if (value.isNotBlank()) { // Можно отправить если есть текст ИЛИ есть reply (как в React Native)
if (value.isNotBlank() || hasReply) {
android.util.Log.d("MessageInputBar", "✅ Calling onSend()") android.util.Log.d("MessageInputBar", "✅ Calling onSend()")
onSend() onSend()
// Очищаем инпут, но клавиатура остаётся открытой // Очищаем инпут, но клавиатура остаётся открытой

View File

@@ -839,6 +839,7 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
* - Поддержка Reply/Forward через attachments (как в React Native) * - Поддержка Reply/Forward через attachments (как в React Native)
*/ */
fun sendMessage() { fun sendMessage() {
android.util.Log.e("REPLY_DEBUG", "🚀🚀🚀 sendMessage() CALLED 🚀🚀🚀")
Log.d(TAG, "🚀🚀🚀 sendMessage() CALLED 🚀🚀🚀") Log.d(TAG, "🚀🚀🚀 sendMessage() CALLED 🚀🚀🚀")
val text = _inputText.value.trim() val text = _inputText.value.trim()
@@ -848,6 +849,7 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
val replyMsgs = _replyMessages.value val replyMsgs = _replyMessages.value
val isForward = _isForwardMode.value val isForward = _isForwardMode.value
android.util.Log.e("REPLY_DEBUG", "📝 Text: '$text', ReplyMsgs: ${replyMsgs.size}")
Log.d(TAG, "📝 Text: '$text'") Log.d(TAG, "📝 Text: '$text'")
Log.d(TAG, "📧 Recipient: ${recipient?.take(16)}") Log.d(TAG, "📧 Recipient: ${recipient?.take(16)}")
Log.d(TAG, "👤 Sender: ${sender?.take(16)}") Log.d(TAG, "👤 Sender: ${sender?.take(16)}")

View File

@@ -22,6 +22,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import com.airbnb.lottie.compose.* import com.airbnb.lottie.compose.*
import com.airbnb.lottie.LottieComposition
import com.rosetta.messenger.R import com.rosetta.messenger.R
import com.rosetta.messenger.network.SearchUser import com.rosetta.messenger.network.SearchUser
import com.rosetta.messenger.ui.components.VerifiedBadge import com.rosetta.messenger.ui.components.VerifiedBadge
@@ -37,6 +38,7 @@ fun SearchResultsList(
isSearching: Boolean, isSearching: Boolean,
currentUserPublicKey: String, currentUserPublicKey: String,
isDarkTheme: Boolean, isDarkTheme: Boolean,
preloadedComposition: LottieComposition? = null,
onUserClick: (SearchUser) -> Unit, onUserClick: (SearchUser) -> Unit,
modifier: Modifier = Modifier modifier: Modifier = Modifier
) { ) {
@@ -89,17 +91,21 @@ fun SearchResultsList(
Column( Column(
horizontalAlignment = Alignment.CenterHorizontally horizontalAlignment = Alignment.CenterHorizontally
) { ) {
// Lottie search animation // Lottie search animation - play once for better performance
val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.search)) // Use preloaded composition if available
val composition = preloadedComposition
val progress by animateLottieCompositionAsState( val progress by animateLottieCompositionAsState(
composition = composition, composition = composition,
iterations = LottieConstants.IterateForever iterations = 1,
isPlaying = true,
restartOnPlay = false
) )
LottieAnimation( LottieAnimation(
composition = composition, composition = composition,
progress = { progress }, progress = { progress },
modifier = Modifier.size(120.dp) modifier = Modifier.size(120.dp),
maintainOriginalImageBounds = true
) )
Spacer(modifier = Modifier.height(20.dp)) Spacer(modifier = Modifier.height(20.dp))

View File

@@ -22,6 +22,8 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import com.airbnb.lottie.compose.*
import com.rosetta.messenger.R
import com.rosetta.messenger.data.RecentSearchesManager import com.rosetta.messenger.data.RecentSearchesManager
import com.rosetta.messenger.network.ProtocolState import com.rosetta.messenger.network.ProtocolState
import com.rosetta.messenger.network.SearchUser import com.rosetta.messenger.network.SearchUser
@@ -58,6 +60,9 @@ fun SearchScreen(
// Recent users (не текстовые запросы, а пользователи) // Recent users (не текстовые запросы, а пользователи)
val recentUsers by RecentSearchesManager.recentUsers.collectAsState() val recentUsers by RecentSearchesManager.recentUsers.collectAsState()
// Preload Lottie composition for search animation
val searchLottieComposition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.search))
// Устанавливаем аккаунт для RecentSearchesManager // Устанавливаем аккаунт для RecentSearchesManager
LaunchedEffect(currentUserPublicKey) { LaunchedEffect(currentUserPublicKey) {
if (currentUserPublicKey.isNotEmpty()) { if (currentUserPublicKey.isNotEmpty()) {
@@ -232,6 +237,7 @@ fun SearchScreen(
isSearching = isSearching, isSearching = isSearching,
currentUserPublicKey = currentUserPublicKey, currentUserPublicKey = currentUserPublicKey,
isDarkTheme = isDarkTheme, isDarkTheme = isDarkTheme,
preloadedComposition = searchLottieComposition,
onUserClick = { user -> onUserClick = { user ->
// Сохраняем пользователя в историю // Сохраняем пользователя в историю
RecentSearchesManager.addUser(user) RecentSearchesManager.addUser(user)