- final var profileFetches = recipientIds.stream().map(recipientId -> {
- var profileKeyCredential = account.getProfileStore().getProfileKeyCredential(recipientId);
- if (profileKeyCredential != null) {
- return null;
- }
-
- return retrieveProfile(recipientId,
- SignalServiceProfile.RequestType.PROFILE_AND_CREDENTIAL).onErrorComplete();
- }).filter(Objects::nonNull).toList();
- Maybe.merge(profileFetches).blockingSubscribe();
+ try {
+ account.getRecipientStore().setBulkUpdating(true);
+ final var profileFetches = Flowable.fromIterable(recipientIds)
+ .filter(recipientId -> account.getProfileStore().getProfileKeyCredential(recipientId) == null)
+ .map(recipientId -> retrieveProfile(recipientId,
+ SignalServiceProfile.RequestType.PROFILE_AND_CREDENTIAL).onErrorComplete());
+ Maybe.merge(profileFetches, 10).blockingSubscribe();
+ } finally {
+ account.getRecipientStore().setBulkUpdating(false);
+ }