diff --git a/src/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java b/src/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java index 2bc5241f58..34d5613a5f 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java @@ -361,17 +361,23 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType { } // Add secondary devices to the list. We shouldn't add our secondary devices - for (Address member : memberSet) { - if (!member.isPhone() || member.serialize().equalsIgnoreCase(localNumber)) { continue; } - try { - List secondaryDevices = PromiseUtil.timeout(LokiStorageAPI.shared.getSecondaryDevicePublicKeys(member.serialize()), 5000).get(); - memberSet.addAll(Stream.of(secondaryDevices).map(string -> { - // Loki - Calling .map(Address::fromSerialized) is causing errors, thus we use the long method :( - return Address.fromSerialized(string); - }).toList()); - } catch (Exception e) { - // Timed out, go to the next member + try { + Set
originalMemberSet = new HashSet<>(memberSet); + for (Address member : originalMemberSet) { + if (!member.isPhone() || member.serialize().equalsIgnoreCase(localNumber)) { continue; } + + try { + List secondaryDevices = PromiseUtil.timeout(LokiStorageAPI.shared.getSecondaryDevicePublicKeys(member.serialize()), 5000).get(); + memberSet.addAll(Stream.of(secondaryDevices).map(string -> { + // Loki - Calling .map(Address::fromSerialized) is causing errors, thus we use the long method :( + return Address.fromSerialized(string); + }).toList()); + } catch (Exception e) { + // Timed out, go to the next member + } } + } catch (Exception e) { + Log.e("PushGroupSend", "Error occurred while adding secondary devices: " + e); } return new LinkedList<>(memberSet);