Skip to content

Commit

Permalink
simplify match case
Browse files Browse the repository at this point in the history
  • Loading branch information
gtalha07 committed Aug 14, 2024
1 parent e7d3390 commit 53cdef2
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions native/acter/src/api/convo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,26 +358,17 @@ impl Convo {

let draft_type = match (draft_type.as_str(), event_id) {
("new", None) => ComposerDraftType::NewMessage,
("edit", id) => {
if let Some(id) = id {
ComposerDraftType::Edit {
event_id: OwnedEventId::try_from(id)?,
}
} else {
bail!("Invalid event id or not found");
}
}
("edit", Some(id)) => ComposerDraftType::Edit {
event_id: OwnedEventId::try_from(id)?,
},

("reply", id) => {
if let Some(id) = id {
ComposerDraftType::Reply {
event_id: OwnedEventId::try_from(id)?,
}
} else {
bail!("Invalid event id or not found");
}
}
_ => bail!("Invalid draft type"),
("reply", Some(id)) => ComposerDraftType::Reply {
event_id: OwnedEventId::try_from(id)?,
},

("reply", _) | ("edit", _) => bail!("Invalid event id"),

(draft_type, _) => bail!("Invalid draft type {draft_type}"),
};

let msg_draft = ComposerDraft {
Expand Down

0 comments on commit 53cdef2

Please sign in to comment.