Prevent crash when adding group member by username.

main
Greyson Parrelli 2023-01-04 09:53:20 -05:00
rodzic 4de27482bb
commit b9fc36be5a
2 zmienionych plików z 5 dodań i 1 usunięć

Wyświetl plik

@ -667,7 +667,7 @@ public final class ContactSelectionListFragment extends LoggingFragment
SelectedContact selectedContact = contact.isUsernameType() ? SelectedContact.forUsername(contact.getRecipientId().orElse(null), contact.getNumber()) SelectedContact selectedContact = contact.isUsernameType() ? SelectedContact.forUsername(contact.getRecipientId().orElse(null), contact.getNumber())
: SelectedContact.forPhone(contact.getRecipientId().orElse(null), contact.getNumber()); : SelectedContact.forPhone(contact.getRecipientId().orElse(null), contact.getNumber());
if (!canSelectSelf && Recipient.self().getId().equals(selectedContact.getOrCreateRecipientId(requireContext()))) { if (!canSelectSelf && !selectedContact.hasUsername() && Recipient.self().getId().equals(selectedContact.getOrCreateRecipientId(requireContext()))) {
Toast.makeText(requireContext(), R.string.ContactSelectionListFragment_you_do_not_need_to_add_yourself_to_the_group, Toast.LENGTH_SHORT).show(); Toast.makeText(requireContext(), R.string.ContactSelectionListFragment_you_do_not_need_to_add_yourself_to_the_group, Toast.LENGTH_SHORT).show();
return; return;
} }

Wyświetl plik

@ -46,6 +46,10 @@ public final class SelectedContact {
} }
} }
public boolean hasUsername() {
return username != null;
}
/** /**
* Returns true when non-null recipient ids match, and false if not. * Returns true when non-null recipient ids match, and false if not.
* <p> * <p>