Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ class CommentRepliesSource(
private val service = NewPipe.getService(commentInfo.serviceId)

override suspend fun load(params: LoadParams<Page>): LoadResult<Page, CommentsInfoItem> {
// params.key is null the first time load() is called, and we need to return the first page
val repliesPage = params.key ?: commentInfo.replies
val info = withContext(Dispatchers.IO) {
CommentsInfo.getMoreItems(service, commentInfo.url, repliesPage)
return try {
// params.key is null the first time load() is called, and we need to return the first page
val repliesPage = params.key ?: commentInfo.replies

val info = withContext(Dispatchers.IO) {
CommentsInfo.getMoreItems(service, commentInfo.url, repliesPage)
}

LoadResult.Page(info.items, null, info.nextPage)
} catch (e: Exception) {
// Catches UnknownHostException (offline) or any extraction errors
// and tells Paging3 to show the error state in the UI.
LoadResult.Error(e)
}
return LoadResult.Page(info.items, null, info.nextPage)
}

override fun getRefreshKey(state: PagingState<Page, CommentsInfoItem>) = null
Expand Down
Loading