diff --git a/app/src/main/java/org/thoughtcrime/securesms/recipients/LiveRecipientCache.java b/app/src/main/java/org/thoughtcrime/securesms/recipients/LiveRecipientCache.java index c531b6a9a0..63069886fe 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/recipients/LiveRecipientCache.java +++ b/app/src/main/java/org/thoughtcrime/securesms/recipients/LiveRecipientCache.java @@ -100,7 +100,7 @@ public final class LiveRecipientCache { */ @AnyThread public void addToCache(@NonNull Collection newRecipients) { - for (Recipient recipient : newRecipients) { + newRecipients.stream().filter(this::isValidForCache).forEach(recipient -> { LiveRecipient live; boolean needsResolve; @@ -131,7 +131,7 @@ public final class LiveRecipientCache { } }); } - } + }); } @NonNull Recipient getSelf() { @@ -205,4 +205,8 @@ public final class LiveRecipientCache { recipients.clear(); } } + + private boolean isValidForCache(@NonNull Recipient recipient) { + return !recipient.getId().isUnknown() && (recipient.hasServiceIdentifier() || recipient.getGroupId().isPresent() || recipient.hasSmsAddress()); + } }