mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-03-30 16:25:57 +00:00
android, desktop: fix navigation to quoted messages in support chats (#5912)
This commit is contained in:
@@ -1415,11 +1415,9 @@ fun BoxScope.ChatItemsList(
|
||||
val chatInfoUpdated = rememberUpdatedState(chatInfo)
|
||||
val scope = rememberCoroutineScope()
|
||||
val scrollToItem: (Long) -> Unit = remember {
|
||||
// In secondary chat just set the itemId to scroll to so the main ChatView will handle scrolling
|
||||
if (chatsCtx.contentTag == MsgContentTag.Report || chatsCtx.secondaryContextFilter is SecondaryContextFilter.GroupChatScopeContext) return@remember { scrollToItemId.value = it }
|
||||
scrollToItem(searchValue, loadingMoreItems, animatedScrollingInProgress, highlightedItems, chatInfoUpdated, maxHeight, scope, reversedChatItems, mergedItems, listState, loadMessages)
|
||||
}
|
||||
val scrollToQuotedItemFromItem: (Long) -> Unit = remember { findQuotedItemFromItem(chatsCtx, remoteHostIdUpdated, chatInfoUpdated, scope, scrollToItem) }
|
||||
val scrollToQuotedItemFromItem: (Long) -> Unit = remember { findQuotedItemFromItem(chatsCtx, remoteHostIdUpdated, chatInfoUpdated, scope, scrollToItem, scrollToItemId) }
|
||||
if (chatsCtx.secondaryContextFilter == null) {
|
||||
LaunchedEffect(Unit) {
|
||||
snapshotFlow { scrollToItemId.value }.filterNotNull().collect {
|
||||
@@ -1484,7 +1482,7 @@ fun BoxScope.ChatItemsList(
|
||||
highlightedItems.value = setOf()
|
||||
}
|
||||
}
|
||||
ChatItemView(chatsCtx, remoteHostId, chatInfo, cItem, composeState, provider, useLinkPreviews = useLinkPreviews, linkMode = linkMode, revealed = revealed, highlighted = highlighted, hoveredItemId = hoveredItemId, range = range, searchIsNotBlank = searchValueIsNotBlank, fillMaxWidth = fillMaxWidth, selectedChatItems = selectedChatItems, selectChatItem = { selectUnselectChatItem(true, cItem, revealed, selectedChatItems, reversedChatItems) }, deleteMessage = deleteMessage, deleteMessages = deleteMessages, archiveReports = archiveReports, receiveFile = receiveFile, cancelFile = cancelFile, joinGroup = joinGroup, acceptCall = acceptCall, acceptFeature = acceptFeature, openDirectChat = openDirectChat, forwardItem = forwardItem, updateContactStats = updateContactStats, updateMemberStats = updateMemberStats, syncContactConnection = syncContactConnection, syncMemberConnection = syncMemberConnection, findModelChat = findModelChat, findModelMember = findModelMember, scrollToItem = scrollToItem, scrollToQuotedItemFromItem = scrollToQuotedItemFromItem, setReaction = setReaction, showItemDetails = showItemDetails, reveal = reveal, showMemberInfo = showMemberInfo, showChatInfo = showChatInfo, developerTools = developerTools, showViaProxy = showViaProxy, itemSeparation = itemSeparation, showTimestamp = itemSeparation.timestamp)
|
||||
ChatItemView(chatsCtx, remoteHostId, chatInfo, cItem, composeState, provider, useLinkPreviews = useLinkPreviews, linkMode = linkMode, revealed = revealed, highlighted = highlighted, hoveredItemId = hoveredItemId, range = range, searchIsNotBlank = searchValueIsNotBlank, fillMaxWidth = fillMaxWidth, selectedChatItems = selectedChatItems, selectChatItem = { selectUnselectChatItem(true, cItem, revealed, selectedChatItems, reversedChatItems) }, deleteMessage = deleteMessage, deleteMessages = deleteMessages, archiveReports = archiveReports, receiveFile = receiveFile, cancelFile = cancelFile, joinGroup = joinGroup, acceptCall = acceptCall, acceptFeature = acceptFeature, openDirectChat = openDirectChat, forwardItem = forwardItem, updateContactStats = updateContactStats, updateMemberStats = updateMemberStats, syncContactConnection = syncContactConnection, syncMemberConnection = syncMemberConnection, findModelChat = findModelChat, findModelMember = findModelMember, scrollToItem = scrollToItem, scrollToItemId = scrollToItemId, scrollToQuotedItemFromItem = scrollToQuotedItemFromItem, setReaction = setReaction, showItemDetails = showItemDetails, reveal = reveal, showMemberInfo = showMemberInfo, showChatInfo = showChatInfo, developerTools = developerTools, showViaProxy = showViaProxy, itemSeparation = itemSeparation, showTimestamp = itemSeparation.timestamp)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2465,7 +2463,8 @@ private fun findQuotedItemFromItem(
|
||||
rhId: State<Long?>,
|
||||
chatInfo: State<ChatInfo>,
|
||||
scope: CoroutineScope,
|
||||
scrollToItem: (Long) -> Unit
|
||||
scrollToItem: (Long) -> Unit,
|
||||
scrollToItemId: MutableState<Long?>
|
||||
): (Long) -> Unit = { itemId: Long ->
|
||||
scope.launch(Dispatchers.Default) {
|
||||
val item = apiLoadSingleMessage(chatsCtx, rhId.value, chatInfo.value.chatType, chatInfo.value.apiId, itemId)
|
||||
@@ -2477,7 +2476,11 @@ private fun findQuotedItemFromItem(
|
||||
chatModel.secondaryChatsContext.value?.updateChatItem(chatInfo.value, item)
|
||||
}
|
||||
if (item.quotedItem?.itemId != null) {
|
||||
scrollToItem(item.quotedItem.itemId)
|
||||
if (item.isReport && chatsCtx.secondaryContextFilter != null) {
|
||||
scrollToItemId.value = item.quotedItem.itemId
|
||||
} else {
|
||||
scrollToItem(item.quotedItem.itemId)
|
||||
}
|
||||
} else {
|
||||
showQuotedItemDoesNotExistAlert()
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ fun ChatItemView(
|
||||
joinGroup: (Long, () -> Unit) -> Unit,
|
||||
acceptCall: (Contact) -> Unit,
|
||||
scrollToItem: (Long) -> Unit,
|
||||
scrollToItemId: MutableState<Long?>,
|
||||
scrollToQuotedItemFromItem: (Long) -> Unit,
|
||||
acceptFeature: (Contact, ChatFeature, Int?) -> Unit,
|
||||
openDirectChat: (Long) -> Unit,
|
||||
@@ -325,7 +326,7 @@ fun ChatItemView(
|
||||
) {
|
||||
@Composable
|
||||
fun framedItemView() {
|
||||
FramedItemView(cInfo, cItem, uriHandler, imageProvider, linkMode = linkMode, showViaProxy = showViaProxy, showMenu, showTimestamp = showTimestamp, tailVisible = itemSeparation.largeGap, receiveFile, onLinkLongClick, scrollToItem, scrollToQuotedItemFromItem)
|
||||
FramedItemView(chatsCtx, cInfo, cItem, uriHandler, imageProvider, linkMode = linkMode, showViaProxy = showViaProxy, showMenu, showTimestamp = showTimestamp, tailVisible = itemSeparation.largeGap, receiveFile, onLinkLongClick, scrollToItem, scrollToItemId, scrollToQuotedItemFromItem)
|
||||
}
|
||||
|
||||
fun deleteMessageQuestionText(): String {
|
||||
@@ -1458,6 +1459,7 @@ fun PreviewChatItemView(
|
||||
joinGroup = { _, _ -> },
|
||||
acceptCall = { _ -> },
|
||||
scrollToItem = {},
|
||||
scrollToItemId = remember { mutableStateOf(null) },
|
||||
scrollToQuotedItemFromItem = {},
|
||||
acceptFeature = { _, _, _ -> },
|
||||
openDirectChat = { _ -> },
|
||||
@@ -1508,6 +1510,7 @@ fun PreviewChatItemViewDeletedContent() {
|
||||
joinGroup = { _, _ -> },
|
||||
acceptCall = { _ -> },
|
||||
scrollToItem = {},
|
||||
scrollToItemId = remember { mutableStateOf(null) },
|
||||
scrollToQuotedItemFromItem = {},
|
||||
acceptFeature = { _, _, _ -> },
|
||||
openDirectChat = { _ -> },
|
||||
|
||||
@@ -27,6 +27,7 @@ import kotlin.math.ceil
|
||||
|
||||
@Composable
|
||||
fun FramedItemView(
|
||||
chatsCtx: ChatModel.ChatsContext,
|
||||
chatInfo: ChatInfo,
|
||||
ci: ChatItem,
|
||||
uriHandler: UriHandler? = null,
|
||||
@@ -39,6 +40,7 @@ fun FramedItemView(
|
||||
receiveFile: (Long) -> Unit,
|
||||
onLinkLongClick: (link: String) -> Unit = {},
|
||||
scrollToItem: (Long) -> Unit = {},
|
||||
scrollToItemId: MutableState<Long?>,
|
||||
scrollToQuotedItemFromItem: (Long) -> Unit = {},
|
||||
) {
|
||||
val sent = ci.chatDir.sent
|
||||
@@ -253,7 +255,11 @@ fun FramedItemView(
|
||||
onLongClick = { showMenu.value = true },
|
||||
onClick = {
|
||||
if (ci.quotedItem.itemId != null) {
|
||||
scrollToItem(ci.quotedItem.itemId)
|
||||
if (ci.isReport && chatsCtx.secondaryContextFilter != null) {
|
||||
scrollToItemId.value = ci.quotedItem.itemId
|
||||
} else {
|
||||
scrollToItem(ci.quotedItem.itemId)
|
||||
}
|
||||
} else {
|
||||
scrollToQuotedItemFromItem(ci.id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user