Repository: android/compose-samples
File: Jetchat/app/src/main/java/com/example/compose/jetchat/conversation/Conversation.kt (Kotlin)

Code before:
                    isUserMe = content.author == authorMe,
                    isFirstMessageByAuthor = isFirstMessageByAuthor,
                    isLastMessageByAuthor = isLastMessageByAuthor
                )
            }
            // Add some space for the top app bar
            item {
                // TODO: Get height from somewhere.
                Spacer(
                    modifier = Modifier
                        .height(90.dp)
                        .statusBarsPadding()
                )
            }
        }
        // Jump to bottom button shows up when user scrolls past a threshold.
        // Convert to pixels:
        val jumpThreshold = with(LocalDensity.current) {
            JumpToBottomThreshold.toPx()
        }

        // Show the button if the first visible item is not the first one or if the offset is
        // greater than the threshold.
        val jumpToBottomButtonEnabled by remember {
            derivedStateOf {
                scrollState.firstVisibleItemIndex != 0 || (
                    scrollState.firstVisibleItemIndex == 0 &&
                        scrollState.firstVisibleItemScrollOffset > jumpThreshold
                    )
            }
        }

        JumpToBottom(
            // Only show if the scroller is not at the bottom
            enabled = jumpToBottomButtonEnabled,
            onClicked = {
                scope.launch {
                    // TODO: Replace with animateScrollToItem
                    // https://issuetracker.google.com/181316785
                    scrollState.scrollToItem(0)
                }
            },
            modifier = Modifier.align(Alignment.BottomCenter)
        )
    }
}

@Composable
fun Message(
    onAuthorClick: () -> Unit,
    msg: Message,

Review comment (suggestion):
Can be simplified to: `scrollState.firstVisibleItemIndex != 0 || scrollState.firstVisibleItemScrollOffset > jumpThreshold`

Code after:
                    isUserMe = content.author == authorMe,
                    isFirstMessageByAuthor = isFirstMessageByAuthor,
                    isLastMessageByAuthor = isLastMessageByAuthor
                )
            }
            // Add some space for the top app bar
            item {
                // TODO: Get height from somewhere.
                Spacer(
                    modifier = Modifier
                        .height(90.dp)
                        .statusBarsPadding()
                )
            }
        }
        // Jump to bottom button shows up when user scrolls past a threshold.
        // Convert to pixels:
        val jumpThreshold = with(LocalDensity.current) {
            JumpToBottomThreshold.toPx()
        }

        // Show the button if the first visible item is not the first one or if the offset is
        // greater than the threshold.
        val jumpToBottomButtonEnabled by remember {
            derivedStateOf {
                scrollState.firstVisibleItemIndex != 0 ||
                    scrollState.firstVisibleItemScrollOffset > jumpThreshold
            }
        }

        JumpToBottom(
            // Only show if the scroller is not at the bottom
            enabled = jumpToBottomButtonEnabled,
            onClicked = {
                scope.launch {
                    // TODO: Replace with animateScrollToItem
                    // https://issuetracker.google.com/181316785
                    scrollState.scrollToItem(0)
                }
            },
            modifier = Modifier.align(Alignment.BottomCenter)
        )
    }
}

@Composable
fun Message(
    onAuthorClick: () -> Unit,
    msg: Message,
    isUserMe: Boolean,
    isFirstMessageByAuthor: Boolean,