Skip to content

Commit e157807

Browse files
Add explanatory comment about creating a new list each time
1 parent f25495d commit e157807

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
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 in AsyncListDiffer
257+
// won't trigger if we send the same list object (https://stackoverflow.com/questions/49726385).
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)