Set instead of List, to avoid duplication.

This commit is contained in:
Benoit Marty 2022-08-22 17:37:29 +02:00 committed by Benoit Marty
parent 9a0ea7bc2e
commit a7666e2112
2 changed files with 3 additions and 3 deletions

View File

@ -24,7 +24,7 @@ internal class SyncResponsePostTreatmentAggregator {
val directChatsToCheck = mutableMapOf<String, String>()
// List of userIds to fetch and update at the end of incremental syncs
val userIdsToFetch = mutableListOf<String>()
val userIdsToFetch = mutableSetOf<String>()
// Set of users to call `crossSigningService.onUsersDeviceUpdate` once per sync
val userIdsWithDeviceUpdate = mutableSetOf<String>()

View File

@ -83,13 +83,13 @@ internal class SyncResponsePostTreatmentAggregatorHandler @Inject constructor(
}
}
private suspend fun fetchAndUpdateUsers(userIdsToFetch: List<String>) {
private suspend fun fetchAndUpdateUsers(userIdsToFetch: Collection<String>) {
fetchUsers(userIdsToFetch)
.takeIf { it.isNotEmpty() }
?.saveLocally()
}
private suspend fun fetchUsers(userIdsToFetch: List<String>) = userIdsToFetch.mapNotNull {
private suspend fun fetchUsers(userIdsToFetch: Collection<String>) = userIdsToFetch.mapNotNull {
tryOrNull {
val profileJson = getProfileInfoTask.execute(GetProfileInfoTask.Params(it))
User.fromJson(it, profileJson)