Skip to content

Commit 3193427

Browse files
committed
Render live chat in CommentSection
1 parent a240aed commit 3193427

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentSection.kt

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private fun CommentSection(
7575
val commentInfo = uiState.data
7676
val count = commentInfo.commentCount
7777

78-
if (commentInfo.isCommentsDisabled) {
78+
if (commentInfo.isCommentsDisabled && !commentInfo.isLiveChat) {
7979
item {
8080
EmptyStateComposable(
8181
spec = EmptyStateSpec.DisabledComments,
@@ -85,7 +85,7 @@ private fun CommentSection(
8585

8686
)
8787
}
88-
} else if (count == 0) {
88+
} else if (count == 0 && !commentInfo.isLiveChat) {
8989
item {
9090
EmptyStateComposable(
9191
spec = EmptyStateSpec.NoComments,
@@ -96,7 +96,7 @@ private fun CommentSection(
9696
}
9797
} else {
9898
// do not show anything if the comment count is unknown
99-
if (count >= 0) {
99+
if (count >= 0 && !commentInfo.isLiveChat) {
100100
item {
101101
Text(
102102
modifier = Modifier
@@ -136,8 +136,19 @@ private fun CommentSection(
136136
}
137137

138138
else -> {
139-
items(comments.itemCount) {
140-
Comment(comment = comments[it]!!) {}
139+
if (comments.itemCount == 0 && commentInfo.isLiveChat) {
140+
item {
141+
EmptyStateComposable(
142+
spec = EmptyStateSpec.NoComments,
143+
modifier = Modifier
144+
.fillMaxWidth()
145+
.heightIn(min = 128.dp)
146+
)
147+
}
148+
} else {
149+
items(comments.itemCount) {
150+
Comment(comment = comments[it]!!) {}
151+
}
141152
}
142153
}
143154
}
@@ -211,7 +222,8 @@ private fun CommentSectionSuccessPreview() {
211222
comments = comments,
212223
nextPage = null,
213224
commentCount = 10,
214-
isCommentsDisabled = false
225+
isCommentsDisabled = false,
226+
isLiveChat = false
215227
)
216228
),
217229
commentsFlow = flowOf(PagingData.from(comments))

0 commit comments

Comments
 (0)