Skip to content

Commit 906abe0

Browse files
committed
fix(fc/chats): handle w/o read observation only if at top
Signed-off-by: Brandon McAnsh <[email protected]>
1 parent be6b57a commit 906abe0

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

flipchatApp/src/main/kotlin/xyz/flipchat/app/features/chat/list/ChatListScreen.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private fun ChatListScreenContent(
133133
contentType = chats.itemContentType { "chat" }
134134
) { index ->
135135
chats[index]?.let {
136-
Column(modifier = Modifier.animateItemPlacement()) {
136+
Column {
137137
ChatNode(
138138
chat = it,
139139
onToggleMute = { mute ->
@@ -192,11 +192,15 @@ private fun ChatListScreenContent(
192192

193193
// opts out of the list maintaining
194194
// scroll position when adding elements before the first item
195+
// we are checking first visible item index to ensure
196+
// the list doesn't shift when scrolled
195197
Snapshot.withoutReadObservation {
196-
listState.requestScrollToItem(
197-
index = listState.firstVisibleItemIndex,
198-
scrollOffset = listState.firstVisibleItemScrollOffset
199-
)
198+
if (listState.firstVisibleItemIndex == 0) {
199+
listState.requestScrollToItem(
200+
index = listState.firstVisibleItemIndex,
201+
scrollOffset = listState.firstVisibleItemScrollOffset
202+
)
203+
}
200204
}
201205
}
202206
}

0 commit comments

Comments
 (0)