Fix matches logic in contact selection.

This commit is contained in:
Alan Evans
2020-05-26 15:29:53 -03:00
committed by Greyson Parrelli
parent fe25d941bb
commit c5e7300df2
2 changed files with 13 additions and 7 deletions

View File

@@ -43,13 +43,19 @@ public final class SelectedContact {
}
/**
* Returns true iff any non-null property matches one on the other contact.
* Returns true when non-null recipient ids match, and false if not.
* <p>
* If one or more recipient id is not set, then it returns true iff any other non-null property
* matches one on the other contact.
*/
public boolean matches(@Nullable SelectedContact other) {
if (other == null) return false;
return recipientId != null && recipientId.equals(other.recipientId) ||
number != null && number .equals(other.number) ||
username != null && username .equals(other.username);
if (recipientId != null && other.recipientId != null) {
return recipientId.equals(other.recipientId);
}
return number != null && number .equals(other.number) ||
username != null && username.equals(other.username);
}
}