MCPcopy Create free account
hub / github.com/chatmail/core / set_draft

Method set_draft

src/chat.rs:715–737  ·  view source on GitHub ↗

Sets draft message. Passing `None` as message just deletes the draft

(self, context: &Context, mut msg: Option<&mut Message>)

Source from the content-addressed store, hash-verified

713 ///
714 /// Passing `None` as message just deletes the draft
715 pub async fn set_draft(self, context: &Context, mut msg: Option<&mut Message>) -> Result<()> {
716 if self.is_special() {
717 return Ok(());
718 }
719
720 let changed = match &mut msg {
721 None => self.maybe_delete_draft(context).await?,
722 Some(msg) => self.do_set_draft(context, msg).await?,
723 };
724
725 if changed {
726 if msg.is_some() {
727 match self.get_draft_msg_id(context).await? {
728 Some(msg_id) => context.emit_msgs_changed(self, msg_id),
729 None => context.emit_msgs_changed_without_msg_id(self),
730 }
731 } else {
732 context.emit_msgs_changed_without_msg_id(self)
733 }
734 }
735
736 Ok(())
737 }
738
739 /// Returns ID of the draft message, if there is one.
740 async fn get_draft_msg_id(self, context: &Context) -> Result<Option<MsgId>> {

Callers 15

test_get_summary_textFunction · 0.45
test_try_loadFunction · 0.45
test_get_summary_unwrapFunction · 0.45
testMethod · 0.45
test_get_draftFunction · 0.45
test_delete_draftFunction · 0.45
test_draft_stable_idsFunction · 0.45

Calls 6

maybe_delete_draftMethod · 0.80
do_set_draftMethod · 0.80
get_draft_msg_idMethod · 0.80
emit_msgs_changedMethod · 0.80
is_specialMethod · 0.45

Tested by 15

test_get_summary_textFunction · 0.36
test_try_loadFunction · 0.36
test_get_summary_unwrapFunction · 0.36
testMethod · 0.36
test_get_draftFunction · 0.36
test_delete_draftFunction · 0.36
test_draft_stable_idsFunction · 0.36