Skip to content

Commit

Permalink
refactor: create_status_update_record: Get rid of notify var
Browse files Browse the repository at this point in the history
It's used in the only place. Also this way `get_webxdc_self_addr()` which makes a db query is only
called when necessary.
  • Loading branch information
iequidoo authored and r10s committed Nov 25, 2024
1 parent 8af90a1 commit 5db574b
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/webxdc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,6 @@ impl Context {
return Ok(None);
};

let notify = if let Some(notify_list) = status_update_item.notify {
let self_addr = instance.get_webxdc_self_addr(self).await?;
notify_list.contains(&self_addr)
} else {
false
};
let mut notify_msg_id = instance.id;
let mut notify_text = "".to_string();
let mut param_changed = false;
Expand Down Expand Up @@ -412,12 +406,17 @@ impl Context {
});
}

if notify && !notify_text.is_empty() && from_id != ContactId::SELF {
self.emit_event(EventType::IncomingWebxdcNotify {
contact_id: from_id,
msg_id: notify_msg_id,
text: notify_text,
});
if !notify_text.is_empty() && from_id != ContactId::SELF {
if let Some(notify_list) = status_update_item.notify {
let self_addr = instance.get_webxdc_self_addr(self).await?;
if notify_list.contains(&self_addr) {
self.emit_event(EventType::IncomingWebxdcNotify {
contact_id: from_id,
msg_id: notify_msg_id,
text: notify_text,
});
}
}
}

Ok(Some(status_update_serial))
Expand Down

0 comments on commit 5db574b

Please sign in to comment.