mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 23:40:33 +05:30
replies performance improvements
This commit is contained in:
parent
e836625223
commit
cfefa87f57
@ -22,6 +22,7 @@ import com.github.libretube.util.NavigationHelper
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class CommentsAdapter(
|
||||
private val videoId: String,
|
||||
@ -126,7 +127,7 @@ class CommentsAdapter(
|
||||
}
|
||||
|
||||
private fun fetchReplies(nextPage: String, onFinished: (CommentsPage) -> Unit) {
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
if (isLoading) return@launch
|
||||
isLoading = true
|
||||
repliesPage = try {
|
||||
@ -135,7 +136,9 @@ class CommentsAdapter(
|
||||
Log.e(TAG(), "IOException, you might not have internet connection")
|
||||
return@launch
|
||||
}
|
||||
withContext(Dispatchers.Main) {
|
||||
onFinished.invoke(repliesPage)
|
||||
}
|
||||
isLoading = false
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user