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 canSend = remember(value) { value.isNotBlank() }
// Состояние отправки - можно отправить если есть текст ИЛИ есть reply
val canSend = remember(value, hasReply) { value.isNotBlank() || hasReply }
// 🔥 Закрываем эмодзи панель когда клавиатура открывается
LaunchedEffect(isKeyboardVisible) {
@@ -1990,8 +1990,9 @@ private fun MessageInputBar(
// Функция отправки - НЕ закрывает клавиатуру (UX правило #6)
fun handleSend() {
android.util.Log.d("MessageInputBar", "🚀 handleSend() called, value='$value', isNotBlank=${value.isNotBlank()}")
if (value.isNotBlank()) {
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,6 +839,7 @@ 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()
@@ -848,6 +849,7 @@ 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)}")

View File

@@ -22,6 +22,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.airbnb.lottie.compose.*
import com.airbnb.lottie.LottieComposition
import com.rosetta.messenger.R
import com.rosetta.messenger.network.SearchUser
import com.rosetta.messenger.ui.components.VerifiedBadge
@@ -37,6 +38,7 @@ fun SearchResultsList(
isSearching: Boolean,
currentUserPublicKey: String,
isDarkTheme: Boolean,
preloadedComposition: LottieComposition? = null,
onUserClick: (SearchUser) -> Unit,
modifier: Modifier = Modifier
) {
@@ -89,17 +91,21 @@ fun SearchResultsList(
Column(
horizontalAlignment = Alignment.CenterHorizontally
) {
// Lottie search animation
val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.search))
// Lottie search animation - play once for better performance
// Use preloaded composition if available
val composition = preloadedComposition
val progress by animateLottieCompositionAsState(
composition = composition,
iterations = LottieConstants.IterateForever
iterations = 1,
isPlaying = true,
restartOnPlay = false
)
LottieAnimation(
composition = composition,
progress = { progress },
modifier = Modifier.size(120.dp)
modifier = Modifier.size(120.dp),
maintainOriginalImageBounds = true
)
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.unit.dp
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.network.ProtocolState
import com.rosetta.messenger.network.SearchUser
@@ -58,6 +60,9 @@ fun SearchScreen(
// Recent users (не текстовые запросы, а пользователи)
val recentUsers by RecentSearchesManager.recentUsers.collectAsState()
// Preload Lottie composition for search animation
val searchLottieComposition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.search))
// Устанавливаем аккаунт для RecentSearchesManager
LaunchedEffect(currentUserPublicKey) {
if (currentUserPublicKey.isNotEmpty()) {
@@ -232,6 +237,7 @@ fun SearchScreen(
isSearching = isSearching,
currentUserPublicKey = currentUserPublicKey,
isDarkTheme = isDarkTheme,
preloadedComposition = searchLottieComposition,
onUserClick = { user ->
// Сохраняем пользователя в историю
RecentSearchesManager.addUser(user)