mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-3298 Chats | Enhancement | Scroll to unread-messages section (#2375)
This commit is contained in:
parent
cc2b2c95a3
commit
c6145046d3
3 changed files with 188 additions and 26 deletions
|
@ -313,7 +313,7 @@ fun ChatScreen(
|
|||
onChatScrolledToBottom: () -> Unit,
|
||||
onScrollToReplyClicked: (Id) -> Unit,
|
||||
onClearIntent: () -> Unit,
|
||||
onScrollToBottomClicked: () -> Unit,
|
||||
onScrollToBottomClicked: (Id?) -> Unit,
|
||||
onVisibleRangeChanged: (Id, Id) -> Unit
|
||||
) {
|
||||
|
||||
|
@ -382,7 +382,7 @@ fun ChatScreen(
|
|||
.mapNotNull { item -> latestMessages.getOrNull(item.index) }
|
||||
.filterIsInstance<ChatView.Message>()
|
||||
|
||||
if (visibleMessages.isNotEmpty()) {
|
||||
if (visibleMessages.isNotEmpty() && !isPerformingScrollIntent.value) {
|
||||
// TODO could be optimised by passing order ID
|
||||
visibleMessages.first().id to visibleMessages.last().id
|
||||
} else null
|
||||
|
@ -468,7 +468,19 @@ fun ChatScreen(
|
|||
.align(Alignment.BottomEnd)
|
||||
.padding(end = 12.dp),
|
||||
onGoToBottomClicked = {
|
||||
onScrollToBottomClicked()
|
||||
val lastVisibleIndex = lazyListState.layoutInfo.visibleItemsInfo.lastOrNull()?.index
|
||||
val lastVisibleView = if (lastVisibleIndex != null) {
|
||||
latestMessages.getOrNull(lastVisibleIndex)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
if (lastVisibleView is ChatView.Message) {
|
||||
onScrollToBottomClicked(
|
||||
lastVisibleView.id
|
||||
)
|
||||
} else {
|
||||
onScrollToBottomClicked(null)
|
||||
}
|
||||
},
|
||||
enabled = jumpToBottomButtonEnabled
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue