use name+addr also for ByContact::SelfName to not get another class of strings that may look like a bug; add a test for that

This commit is contained in:
B. Petersen
2022-11-15 11:37:13 +01:00
parent 1928adbe3d
commit 46b90e206e
2 changed files with 46 additions and 27 deletions

View File

@@ -282,18 +282,21 @@ impl Context {
}
}
pub async fn get_config_self_name(&self) -> String {
match self
pub async fn get_config_name_and_addr(&self) -> String {
let name = self
.get_config(Config::Displayname)
.await
.unwrap_or_default()
{
Some(name) => name,
None => self
.get_config(Config::Addr)
.await
.unwrap_or_default()
.unwrap_or_default(),
.unwrap_or_default();
let addr = self
.get_config(Config::Addr)
.await
.unwrap_or_default()
.unwrap_or_else(|| "unconfigured".to_string());
if !name.is_empty() {
format!("{} ({})", name, addr)
} else {
addr
}
}