We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ef2c07b commit 3b1f0bcCopy full SHA for 3b1f0bc
1 file changed
app/src/main/java/com/github/libretube/ui/models/sources/CommentPagingSource.kt
@@ -18,11 +18,14 @@ class CommentPagingSource(
18
val result = withContext(Dispatchers.IO) {
19
params.key?.let {
20
MediaServiceRepository.instance.getCommentsNextPage(videoId, it)
21
- } ?: MediaServiceRepository.instance.getComments(videoId)
+ } ?: MediaServiceRepository.instance.getComments(videoId).also {
22
+ // avoid negative comment counts, i.e. because they're disabled
23
+ withContext(Dispatchers.Main) {
24
+ onCommentCount(maxOf(0, it.commentCount))
25
+ }
26
27
}
28
- if (result.commentCount > 0) onCommentCount(result.commentCount)
-
29
LoadResult.Page(result.comments, null, result.nextpage)
30
} catch (e: Exception) {
31
LoadResult.Error(e)
0 commit comments