File tree Expand file tree Collapse file tree
app/src/main/java/org/schabi/newpipe
ui/components/video/comment Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ class CommentInfo(
1313 val nextPage : Page ? ,
1414 val commentCount : Int ,
1515 val isCommentsDisabled : Boolean ,
16- val isLiveChat : Boolean = false
16+ val isLiveChat : Boolean
1717) {
1818 constructor (commentsInfo: CommentsInfo ) : this (
1919 commentsInfo.serviceId,
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import androidx.compose.material3.MaterialTheme
1212import androidx.compose.material3.Surface
1313import androidx.compose.material3.Text
1414import androidx.compose.runtime.Composable
15+ import androidx.compose.runtime.LaunchedEffect
1516import androidx.compose.runtime.getValue
1617import androidx.compose.ui.Alignment
1718import androidx.compose.ui.Modifier
@@ -59,6 +60,14 @@ private fun CommentSection(
5960 val nestedScrollInterop = rememberNestedScrollInteropConnection()
6061 val state = rememberLazyListState()
6162
63+ // Auto-scroll to top when new live chat messages arrive
64+ val isLiveChat = uiState is Resource .Success && uiState.data.isLiveChat
65+ LaunchedEffect (liveChatItems.size) {
66+ if (isLiveChat && liveChatItems.isNotEmpty()) {
67+ state.scrollToItem(0 )
68+ }
69+ }
70+
6271 LazyColumnThemedScrollbar (state = state) {
6372 LazyColumn (
6473 modifier = Modifier
Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ import kotlinx.coroutines.flow.SharingStarted
1717import kotlinx.coroutines.flow.StateFlow
1818import kotlinx.coroutines.flow.filterIsInstance
1919import kotlinx.coroutines.flow.flatMapLatest
20- import kotlinx.coroutines.flow.flowOf
2120import kotlinx.coroutines.flow.flowOn
2221import kotlinx.coroutines.flow.map
2322import kotlinx.coroutines.flow.stateIn
You can’t perform that action at this time.
0 commit comments