Skip to content

Commit

Permalink
Add explanatory comment about creating a new list each time
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Sep 20, 2024
1 parent d9559d2 commit e0dc712
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,13 @@ class ThreadViewModel @Inject constructor(

val batch = input.take(batchSize)
output.addAll(batch)
batchedMessages.postValue(output.toMutableList())
if (batch.size < batchSize) return

delay(50L)
// We need to post a different list each time, because the `submitList` function in AsyncListDiffer
// won't trigger if we send the same list object (https://stackoverflow.com/questions/49726385).
batchedMessages.postValue(ArrayList(output))

if (batch.size < batchSize) return
delay(50L)
sendBatchesRecursively(input.subList(batchSize, input.size), output)
}

Expand Down

0 comments on commit e0dc712

Please sign in to comment.