mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
Use Vec::first to avoid explicit is_empty() check
This commit is contained in:
committed by
holger krekel
parent
47b937f880
commit
06bc5513ae
12
src/chat.rs
12
src/chat.rs
@@ -91,8 +91,8 @@ impl Chat {
|
|||||||
let contacts = get_chat_contacts(context, chat.id);
|
let contacts = get_chat_contacts(context, chat.id);
|
||||||
let mut chat_name = "Err [Name not found]".to_owned();
|
let mut chat_name = "Err [Name not found]".to_owned();
|
||||||
|
|
||||||
if !(*contacts).is_empty() {
|
if let Some(contact_id) = contacts.first() {
|
||||||
if let Ok(contact) = Contact::get_by_id(context, contacts[0]) {
|
if let Ok(contact) = Contact::get_by_id(context, *contact_id) {
|
||||||
chat_name = contact.get_display_name().to_owned();
|
chat_name = contact.get_display_name().to_owned();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,8 +209,8 @@ impl Chat {
|
|||||||
}
|
}
|
||||||
} else if self.typ == Chattype::Single {
|
} else if self.typ == Chattype::Single {
|
||||||
let contacts = get_chat_contacts(context, self.id);
|
let contacts = get_chat_contacts(context, self.id);
|
||||||
if !contacts.is_empty() {
|
if let Some(contact_id) = contacts.first() {
|
||||||
if let Ok(contact) = Contact::get_by_id(context, contacts[0]) {
|
if let Ok(contact) = Contact::get_by_id(context, *contact_id) {
|
||||||
return contact.get_profile_image(context);
|
return contact.get_profile_image(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -228,8 +228,8 @@ impl Chat {
|
|||||||
|
|
||||||
if self.typ == Chattype::Single {
|
if self.typ == Chattype::Single {
|
||||||
let contacts = get_chat_contacts(context, self.id);
|
let contacts = get_chat_contacts(context, self.id);
|
||||||
if !contacts.is_empty() {
|
if let Some(contact_id) = contacts.first() {
|
||||||
if let Ok(contact) = Contact::get_by_id(context, contacts[0]) {
|
if let Ok(contact) = Contact::get_by_id(context, *contact_id) {
|
||||||
color = contact.get_color();
|
color = contact.get_color();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user