Skip to content

Commit 5db574b

Browse files
iequidoor10s
authored andcommitted
refactor: create_status_update_record: Get rid of notify var
It's used in the only place. Also this way `get_webxdc_self_addr()` which makes a db query is only called when necessary.
1 parent 8af90a1 commit 5db574b

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/webxdc.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,6 @@ impl Context {
326326
return Ok(None);
327327
};
328328

329-
let notify = if let Some(notify_list) = status_update_item.notify {
330-
let self_addr = instance.get_webxdc_self_addr(self).await?;
331-
notify_list.contains(&self_addr)
332-
} else {
333-
false
334-
};
335329
let mut notify_msg_id = instance.id;
336330
let mut notify_text = "".to_string();
337331
let mut param_changed = false;
@@ -412,12 +406,17 @@ impl Context {
412406
});
413407
}
414408

415-
if notify && !notify_text.is_empty() && from_id != ContactId::SELF {
416-
self.emit_event(EventType::IncomingWebxdcNotify {
417-
contact_id: from_id,
418-
msg_id: notify_msg_id,
419-
text: notify_text,
420-
});
409+
if !notify_text.is_empty() && from_id != ContactId::SELF {
410+
if let Some(notify_list) = status_update_item.notify {
411+
let self_addr = instance.get_webxdc_self_addr(self).await?;
412+
if notify_list.contains(&self_addr) {
413+
self.emit_event(EventType::IncomingWebxdcNotify {
414+
contact_id: from_id,
415+
msg_id: notify_msg_id,
416+
text: notify_text,
417+
});
418+
}
419+
}
421420
}
422421

423422
Ok(Some(status_update_serial))

0 commit comments

Comments
 (0)