diff --git a/app/src/main/java/com/rosetta/messenger/ui/chats/ChatDetailScreen.kt b/app/src/main/java/com/rosetta/messenger/ui/chats/ChatDetailScreen.kt index 5c70100..1031d06 100644 --- a/app/src/main/java/com/rosetta/messenger/ui/chats/ChatDetailScreen.kt +++ b/app/src/main/java/com/rosetta/messenger/ui/chats/ChatDetailScreen.kt @@ -1388,6 +1388,14 @@ fun ChatDetailScreen( com.rosetta.messenger.ui.components.EmojiCache.preload(context) } + // Consume pending forward messages for this chat + LaunchedEffect(user.publicKey, forwardTrigger) { + val pendingForwards = ForwardManager.consumeForwardMessagesForChat(user.publicKey) + if (pendingForwards.isNotEmpty()) { + viewModel.sendForwardDirectly(user.publicKey, pendingForwards) + } + } + // Отмечаем сообщения как прочитанные только когда экран активен (RESUMED) LaunchedEffect(messages, isScreenActive) { if (messages.isNotEmpty() && isScreenActive) { @@ -1440,8 +1448,7 @@ fun ChatDetailScreen( messagesWithDates.isNotEmpty() && floatingDateText != null && !isAtBottom && - (listState.isScrollInProgress || - listState.firstVisibleItemIndex > 0) + listState.isScrollInProgress } } diff --git a/app/src/main/java/com/rosetta/messenger/ui/chats/components/ChatDetailComponents.kt b/app/src/main/java/com/rosetta/messenger/ui/chats/components/ChatDetailComponents.kt index 40f2ee4..65f9bf5 100644 --- a/app/src/main/java/com/rosetta/messenger/ui/chats/components/ChatDetailComponents.kt +++ b/app/src/main/java/com/rosetta/messenger/ui/chats/components/ChatDetailComponents.kt @@ -2383,6 +2383,7 @@ fun ForwardedMessagesBubble( onMentionClick: (username: String) -> Unit = {}, onTextSpanPressStart: (() -> Unit)? = null ) { + val configuration = androidx.compose.ui.platform.LocalConfiguration.current val backgroundColor = if (isOutgoing) Color.Black.copy(alpha = 0.1f) else Color.Black.copy(alpha = 0.05f) @@ -2406,9 +2407,11 @@ fun ForwardedMessagesBubble( }.toMap() } + val maxBubbleWidth = (configuration.screenWidthDp * 0.65f).dp + Column( modifier = Modifier - .fillMaxWidth() + .widthIn(max = maxBubbleWidth) .clip(RoundedCornerShape(4.dp)) .background(backgroundColor) ) { @@ -2439,29 +2442,24 @@ fun ForwardedMessagesBubble( } // "Forwarded from [Name]" — clickable to open profile - Row( - verticalAlignment = Alignment.CenterVertically, + Text( + text = buildAnnotatedString { + withStyle(SpanStyle( + color = nameColor.copy(alpha = 0.7f), + fontWeight = FontWeight.Normal + )) { append("Forwarded from ") } + withStyle(SpanStyle( + color = nameColor, + fontWeight = FontWeight.Bold + )) { append(fwd.forwardedFromName.ifEmpty { "User" }) } + }, + fontSize = 13.sp, + maxLines = 1, + overflow = TextOverflow.Ellipsis, modifier = Modifier.clickable(enabled = fwd.senderPublicKey.isNotEmpty()) { onForwardedSenderClick(fwd.senderPublicKey) } - ) { - Text( - text = "Forwarded from ", - color = nameColor.copy(alpha = 0.7f), - fontSize = 13.sp, - fontWeight = FontWeight.Normal, - maxLines = 1 - ) - Text( - text = fwd.forwardedFromName.ifEmpty { "User" }, - color = nameColor, - fontSize = 13.sp, - fontWeight = FontWeight.Bold, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - modifier = Modifier.weight(1f, fill = false) - ) - } + ) // Attachments (images) — before text (text acts as caption) val imageAttachments = fwd.attachments.filter { it.type == AttachmentType.IMAGE } @@ -2611,10 +2609,11 @@ private fun ForwardedImagePreview( } } - val maxPhotoWidthDp = TelegramBubbleSpec.maxPhotoWidth(configuration.screenWidthDp).dp - val minPhotoWidthDp = TelegramBubbleSpec.minPhotoWidth.dp - val minPhotoHeightDp = TelegramBubbleSpec.minPhotoHeight.dp - val maxPhotoHeightDp = TelegramBubbleSpec.maxPhotoHeight.dp + // Forwarded images use smaller max size to fit inside the forward bubble + val maxPhotoWidthDp = (configuration.screenWidthDp * 0.55f).toInt().dp + val minPhotoWidthDp = 100.dp + val minPhotoHeightDp = 80.dp + val maxPhotoHeightDp = 280.dp val (previewWidth, previewHeight) = remember( attachment.width,