Avoid ChatId::is_unset for searching messages

Using a ChatId value of 0 to indicate global search is a left over
from C-land.  Refactor this to be an option instead.
This commit is contained in:
Floris Bruynooghe
2021-02-08 22:12:33 +01:00
parent 6aeda98c0a
commit 65fb2d791b
3 changed files with 52 additions and 39 deletions
+6 -1
View File
@@ -1136,10 +1136,15 @@ pub unsafe extern "C" fn dc_search_msgs(
return ptr::null_mut();
}
let ctx = &*context;
let chat_id = if chat_id == 0 {
None
} else {
Some(ChatId::new(chat_id))
};
block_on(async move {
let arr = dc_array_t::from(
ctx.search_msgs(ChatId::new(chat_id), to_string_lossy(query))
ctx.search_msgs(chat_id, to_string_lossy(query))
.await
.iter()
.map(|msg_id| msg_id.to_u32())