Merge pull request #455 from deltachat/fix-msg-loading

Fix msg loading
This commit is contained in:
björn petersen
2019-09-07 15:37:38 +02:00
committed by GitHub
3 changed files with 7 additions and 6 deletions

View File

@@ -428,7 +428,7 @@ pub unsafe fn dc_cmdline(context: &Context, line: &str) -> Result<(), failure::E
send <text>\n\
send-garbage\n\
sendimage <file> [<text>]\n\
sendfile <file>\n\
sendfile <file> [<text>]\n\
draft [<text>]\n\
listmedia\n\
archive <chat-id>\n\
@@ -862,7 +862,7 @@ pub unsafe fn dc_cmdline(context: &Context, line: &str) -> Result<(), failure::E
}
"sendimage" | "sendfile" => {
ensure!(sel_chat.is_some(), "No chat selected.");
ensure!(!arg1.is_empty() && !arg2.is_empty(), "No file given.");
ensure!(!arg1.is_empty(), "No file given.");
let mut msg = dc_msg_new(
context,
@@ -873,7 +873,9 @@ pub unsafe fn dc_cmdline(context: &Context, line: &str) -> Result<(), failure::E
},
);
dc_msg_set_file(&mut msg, arg1_c, ptr::null());
dc_msg_set_text(&mut msg, arg2_c);
if !arg2.is_empty() {
dc_msg_set_text(&mut msg, arg2_c);
}
chat::send_msg(context, sel_chat.as_ref().unwrap().get_id(), &mut msg)?;
}
"listmsgs" => {

View File

@@ -502,7 +502,7 @@ impl<'a> Chat<'a> {
timestamp,
msg.type_0,
msg.state,
msg.text,
msg.text.as_ref().map_or("", String::as_str),
msg.param.to_string(),
msg.hidden,
to_string(new_in_reply_to),

View File

@@ -478,8 +478,7 @@ pub fn dc_msg_load_from_db<'a>(context: &'a Context, id: u32) -> Result<Message<
text = String::from_utf8_lossy(buf).into_owned();
}
} else {
warn!(context, 0, "dc_msg_load_from_db: could not get text column for id {}", id);
text = "[ Could not read from db ]".to_string();
text = "".to_string();
}
msg.text = Some(text);