mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-04-06 23:55:55 +00:00
android, desktop: don't load new messages when pressing quote while searching (#5315)
This commit is contained in:
committed by
GitHub
parent
89f380400e
commit
219381f941
@@ -1001,7 +1001,7 @@ fun BoxScope.ChatItemsList(
|
||||
val chatInfoUpdated = rememberUpdatedState(chatInfo)
|
||||
val highlightedItems = remember { mutableStateOf(setOf<Long>()) }
|
||||
val scope = rememberCoroutineScope()
|
||||
val scrollToItem: (Long) -> Unit = remember { scrollToItem(loadingMoreItems, highlightedItems, chatInfoUpdated, maxHeight, scope, reversedChatItems, mergedItems, listState, loadMessages) }
|
||||
val scrollToItem: (Long) -> Unit = remember { scrollToItem(searchValue, loadingMoreItems, highlightedItems, chatInfoUpdated, maxHeight, scope, reversedChatItems, mergedItems, listState, loadMessages) }
|
||||
val scrollToQuotedItemFromItem: (Long) -> Unit = remember { findQuotedItemFromItem(remoteHostIdUpdated, chatInfoUpdated, scope, scrollToItem) }
|
||||
|
||||
LoadLastItems(loadingMoreItems, remoteHostId, chatInfo)
|
||||
@@ -1834,6 +1834,7 @@ private fun lastFullyVisibleIemInListState(topPaddingToContentPx: State<Int>, de
|
||||
}
|
||||
|
||||
private fun scrollToItem(
|
||||
searchValue: State<String>,
|
||||
loadingMoreItems: MutableState<Boolean>,
|
||||
highlightedItems: MutableState<Set<Long>>,
|
||||
chatInfo: State<ChatInfo>,
|
||||
@@ -1847,6 +1848,8 @@ private fun scrollToItem(
|
||||
withApi {
|
||||
try {
|
||||
var index = mergedItems.value.indexInParentItems[itemId] ?: -1
|
||||
// Don't try to load messages while in search
|
||||
if (index == -1 && searchValue.value.isNotBlank()) return@withApi
|
||||
// setting it to 'loading' even if the item is loaded because in rare cases when the resulting item is near the top, scrolling to
|
||||
// it will trigger loading more items and will scroll to incorrect position (because of trimming)
|
||||
loadingMoreItems.value = true
|
||||
|
||||
Reference in New Issue
Block a user