Merge pull request #7254 from Bnyro/master

fix: comment count doesn't reset to 0 if comments disabled
This commit is contained in:
Bnyro 2025-03-31 15:11:59 +02:00 committed by GitHub
commit 3debc48b55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)