From 6e14585a12cb2d6bbf1beb8ce32c72e467ff4ce0 Mon Sep 17 00:00:00 2001 From: James Magahern Date: Fri, 27 Jun 2025 00:48:20 -0700 Subject: [PATCH] EDS: Found the issue where address book sometimes doesn't load -v The wrong source was getting selected. Not sure if this one is always a decoy, there might be others that we aren't supposed to use. Happy that it's working now though. --- .../src/daemon/contact_resolver/eds.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/kordophoned/src/daemon/contact_resolver/eds.rs b/kordophoned/src/daemon/contact_resolver/eds.rs index 06abc40..42e2baf 100644 --- a/kordophoned/src/daemon/contact_resolver/eds.rs +++ b/kordophoned/src/daemon/contact_resolver/eds.rs @@ -114,6 +114,11 @@ fn ensure_address_book_uid(conn: &Connection) -> anyhow::Result { .filter_map(|ifaces| ifaces.get("org.gnome.evolution.dataserver.Source")) .filter_map(|props| { let uid = props.get("UID")?.as_str()?; + if uid == "system-address-book" { + // Decoy. + return None; + } + let data = props.get("Data")?.as_str()?; if data_contains_address_book_backend(data) { Some(uid.to_owned()) @@ -199,11 +204,16 @@ impl ContactResolverBackend for EDSContactResolverBackend { let filter = if address.contains('@') { format!("(is \"email\" \"{}\")", address) } else { + let mut filters: Vec = Vec::new(); + filters.push(format!("(is \"phone\" \"{}\")", address)); + let normalized_address = address .chars() .filter(|c| c.is_numeric()) .collect::(); + filters.push(format!("(is \"phone\" \"{}\")", normalized_address)); + let local_address = address .replace('+', "") .chars() @@ -213,10 +223,11 @@ impl ContactResolverBackend for EDSContactResolverBackend { .filter(|c| c.is_numeric()) .collect::(); - format!( - "(or (is \"phone\" \"{}\") (is \"phone\" \"{}\") (is \"phone\" \"{}\"))", - address, normalized_address, local_address - ) + if !local_address.is_empty() { + filters.push(format!("(is \"phone\" \"{}\")", local_address)); + } + + format!("(or {})", filters.join(" ")) }; log::trace!(