diff --git a/app/src/main/java/com/github/libretube/ui/models/sources/CommentPagingSource.kt b/app/src/main/java/com/github/libretube/ui/models/sources/CommentPagingSource.kt index 38f2a8298..25b1e760c 100644 --- a/app/src/main/java/com/github/libretube/ui/models/sources/CommentPagingSource.kt +++ b/app/src/main/java/com/github/libretube/ui/models/sources/CommentPagingSource.kt @@ -18,11 +18,14 @@ class CommentPagingSource( val result = withContext(Dispatchers.IO) { params.key?.let { MediaServiceRepository.instance.getCommentsNextPage(videoId, it) - } ?: MediaServiceRepository.instance.getComments(videoId) + } ?: MediaServiceRepository.instance.getComments(videoId).also { + // avoid negative comment counts, i.e. because they're disabled + withContext(Dispatchers.Main) { + onCommentCount(maxOf(0, it.commentCount)) + } + } } - if (result.commentCount > 0) onCommentCount(result.commentCount) - LoadResult.Page(result.comments, null, result.nextpage) } catch (e: Exception) { LoadResult.Error(e)