mirror of
https://github.com/chatmail/core.git
synced 2026-05-04 05:46:29 +03:00
Factor another part of set_draft_raw into separate function
This commit is contained in:
20
src/chat.rs
20
src/chat.rs
@@ -867,12 +867,12 @@ fn maybe_delete_draft(context: &Context, chat_id: u32) -> bool {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
// similar to as dc_set_draft() but does not emit an event
|
/// Set provided message as draft message for specified chat.
|
||||||
#[allow(non_snake_case)]
|
///
|
||||||
unsafe fn set_draft_raw(context: &Context, chat_id: u32, msg: &mut Message) -> bool {
|
/// Return true on success, false on database error.
|
||||||
|
fn do_set_draft(context: &Context, chat_id: u32, msg: &mut Message) -> bool {
|
||||||
let mut OK_TO_CONTINUE = true;
|
let mut OK_TO_CONTINUE = true;
|
||||||
|
let mut sth_changed = false;
|
||||||
let mut sth_changed = maybe_delete_draft(context, chat_id);
|
|
||||||
|
|
||||||
// save new draft
|
// save new draft
|
||||||
if msg.type_0 == Viewtype::Text {
|
if msg.type_0 == Viewtype::Text {
|
||||||
@@ -916,6 +916,16 @@ unsafe fn set_draft_raw(context: &Context, chat_id: u32, msg: &mut Message) -> b
|
|||||||
sth_changed
|
sth_changed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// similar to as dc_set_draft() but does not emit an event
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
unsafe fn set_draft_raw(context: &Context, chat_id: u32, msg: &mut Message) -> bool {
|
||||||
|
let deleted = maybe_delete_draft(context, chat_id);
|
||||||
|
let set = do_set_draft(context, chat_id, msg);
|
||||||
|
|
||||||
|
// Can't inline. Both functions above must be called, no shortcut!
|
||||||
|
deleted || set
|
||||||
|
}
|
||||||
|
|
||||||
fn get_draft_msg_id(context: &Context, chat_id: u32) -> u32 {
|
fn get_draft_msg_id(context: &Context, chat_id: u32) -> u32 {
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
|
|||||||
Reference in New Issue
Block a user