Use sender onion when we don't have a contact (now will null safety)

This commit is contained in:
Sarah Jamie Lewis 2021-05-28 15:23:36 -07:00
parent cf3e3961ee
commit d5dbecddfa
1 changed files with 6 additions and 2 deletions

View File

@ -29,8 +29,12 @@ class MessageBubbleState extends State<MessageBubble> {
// If the sender is not us, then we want to give them a nickname...
var senderDisplayStr = "";
if (!fromMe && Provider.of<MessageState>(context).senderOnion != null) {
var contact = Provider.of<ProfileInfoState>(context).contactList.getContact(Provider.of<MessageState>(context).senderOnion);
senderDisplayStr = contact!.nickname;
ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.getContact(Provider.of<MessageState>(context).senderOnion);
if (contact != null) {
senderDisplayStr = contact.nickname;
} else {
senderDisplayStr = Provider.of<MessageState>(context).senderOnion;
}
}
var wdgSender = SelectableText(senderDisplayStr,
style: TextStyle(fontSize: 9.0, color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeTextColor() : Provider.of<Settings>(context).theme.messageFromOtherTextColor()));