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 09793a57db..89657fe387 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/recipients/LiveRecipientCache.java +++ b/app/src/main/java/org/thoughtcrime/securesms/recipients/LiveRecipientCache.java @@ -150,16 +150,20 @@ public final class LiveRecipientCache { ACI localAci = SignalStore.account().getAci(); String localE164 = SignalStore.account().getE164(); - if (localAci != null) { - selfId = recipientDatabase.getByServiceId(localAci).or(recipientDatabase.getByE164(localE164)).orNull(); - } else if (localE164 != null) { - selfId = recipientDatabase.getByE164(localE164).orNull(); - } else { + if (localAci == null && localE164 == null) { throw new IllegalStateException("Tried to call getSelf() before local data was set!"); } + if (localAci != null) { + selfId = recipientDatabase.getByServiceId(localAci).orNull(); + } + + if (selfId == null && localE164 != null) { + selfId = recipientDatabase.getByE164(localE164).orNull(); + } + if (selfId == null) { - selfId = recipientDatabase.getAndPossiblyMerge(localAci, localE164, false); + selfId = recipientDatabase.getAndPossiblyMerge(localAci, localE164, true); } synchronized (localRecipientId) {