From 45e55c963e3ed8e889ba344c9f07616a7f2c7746 Mon Sep 17 00:00:00 2001 From: iequidoo Date: Fri, 29 Nov 2024 16:12:13 -0300 Subject: [PATCH] refactor: Use Option::or_else() to dedup emitting IncomingWebxdcNotify --- src/webxdc.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/webxdc.rs b/src/webxdc.rs index f43e45f25c..5477a1bd70 100644 --- a/src/webxdc.rs +++ b/src/webxdc.rs @@ -417,14 +417,9 @@ impl Context { if from_id != ContactId::SELF { if let Some(notify_list) = status_update_item.notify { let self_addr = instance.get_webxdc_self_addr(self).await?; - if let Some(notify_text) = notify_list.get(&self_addr) { - self.emit_event(EventType::IncomingWebxdcNotify { - contact_id: from_id, - msg_id: notify_msg_id, - text: notify_text.clone(), - href: status_update_item.href, - }); - } else if let Some(notify_text) = notify_list.get("*") { + if let Some(notify_text) = + notify_list.get(&self_addr).or_else(|| notify_list.get("*")) + { self.emit_event(EventType::IncomingWebxdcNotify { contact_id: from_id, msg_id: notify_msg_id,