Skip to content

Commit 4cf2c97

Browse files
Add explanatory comment about creating a new list each time
1 parent be7e695 commit 4cf2c97

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Diff for: app/src/main/java/com/infomaniak/mail/ui/main/thread/ThreadViewModel.kt

+5-3
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,13 @@ class ThreadViewModel @Inject constructor(
252252

253253
val batch = input.take(batchSize)
254254
output.addAll(batch)
255-
batchedMessages.postValue(output.toMutableList())
256-
if (batch.size < batchSize) return
257255

258-
delay(50L)
256+
// We need to post a different list each time, because the `submitList` function
257+
// in AsyncListDiffer won't trigger if we send the same list object.
258+
batchedMessages.postValue(ArrayList(output))
259259

260+
if (batch.size < batchSize) return
261+
delay(50L)
260262
sendBatchesRecursively(input.subList(batchSize, input.size), output)
261263
}
262264

0 commit comments

Comments
 (0)