fix: crash when trying to dearrow feed items

This commit is contained in:
Bnyro 2024-05-07 12:28:14 +02:00
parent 800d6704cf
commit 278ba4ea32

View File

@ -212,20 +212,22 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment() {
if (viewModel.videoFeed.value != null && !isCurrentTabSubChannels && !binding.subRefresh.isRefreshing && hasMore) {
binding.subRefresh.isRefreshing = true
lifecycleScope.launch(Dispatchers.IO) {
lifecycleScope.launch {
val toIndex = minOf(feedAdapter.itemCount + 10, sortedFeed.size)
val streamItemsToInsert = sortedFeed
var streamItemsToInsert = sortedFeed
.subList(feedAdapter.itemCount, toIndex)
.deArrow()
.toList()
withContext(Dispatchers.IO) {
runCatching { streamItemsToInsert = streamItemsToInsert.deArrow() }
}
withContext(Dispatchers.Main) {
feedAdapter.insertItems(streamItemsToInsert)
binding.subRefresh.isRefreshing = false
}
}
}
}
private fun setupSortAndFilter() {
binding.filterSort.setOnClickListener {