Refactor LiveRecipient fetch to be more clear.

This commit is contained in:
Greyson Parrelli
2022-02-20 23:39:42 -05:00
parent 19dc90b68b
commit 97f8b5988d

View File

@@ -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) {