mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 23:40:33 +05:30
fix: comment count doesn't reset to 0 if comments disabled
This commit is contained in:
parent
ef2c07bf03
commit
3b1f0bc7bb
@ -18,11 +18,14 @@ class CommentPagingSource(
|
|||||||
val result = withContext(Dispatchers.IO) {
|
val result = withContext(Dispatchers.IO) {
|
||||||
params.key?.let {
|
params.key?.let {
|
||||||
MediaServiceRepository.instance.getCommentsNextPage(videoId, it)
|
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)
|
LoadResult.Page(result.comments, null, result.nextpage)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
LoadResult.Error(e)
|
LoadResult.Error(e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user