@@ -59,10 +59,7 @@ import com.infomaniak.mail.utils.RealmChangesBinding
59
59
import com.infomaniak.mail.utils.Utils.runCatchingRealm
60
60
import com.infomaniak.mail.utils.extensions.*
61
61
import dagger.hilt.android.qualifiers.ActivityContext
62
- import kotlinx.coroutines.CoroutineScope
63
- import kotlinx.coroutines.Dispatchers
64
- import kotlinx.coroutines.invoke
65
- import kotlinx.coroutines.launch
62
+ import kotlinx.coroutines.*
66
63
import javax.inject.Inject
67
64
import kotlin.math.abs
68
65
import com.google.android.material.R as RMaterial
@@ -75,6 +72,7 @@ class ThreadListAdapter @Inject constructor(
75
72
private val globalCoroutineScope : CoroutineScope ,
76
73
) : DragDropSwipeAdapter<Any, ThreadListViewHolder>(mutableListOf()), RealmChangesBinding.OnRealmChanged<Thread> {
77
74
75
+ private var formatListJob: Job ? = null
78
76
private lateinit var recyclerView: RecyclerView
79
77
80
78
override val realmAsyncListDiffer: AsyncListDiffer <Thread >? = null
@@ -556,7 +554,9 @@ class ThreadListAdapter @Inject constructor(
556
554
override fun createDiffUtil (oldList : List <Any >, newList : List <Any >): DragDropSwipeDiffCallback <Any >? = null
557
555
558
556
override fun updateList (itemList : List <Thread >) {
559
- globalCoroutineScope.launch {
557
+
558
+ formatListJob?.cancel()
559
+ formatListJob = globalCoroutineScope.launch {
560
560
561
561
val formattedList = runCatchingRealm {
562
562
formatList(itemList, recyclerView.context, folderRole, localSettings.threadDensity).apply {
0 commit comments