mirror of
https://github.com/chatmail/core.git
synced 2026-04-28 19:06:35 +03:00
chat: get rid of ChatId.is_error()
get_rowid should not return 0, as we have inserted a row right above. And using is_error() instead of comparing row_id to 0 is a strange way to check this condition. As all functions that actually returned 0 chat ID to indicate error have been removed, the function is gone too.
This commit is contained in:
committed by
link2xt
parent
17a13f0f83
commit
f0f020d9d2
14
src/chat.rs
14
src/chat.rs
@@ -39,18 +39,9 @@ impl ChatId {
|
|||||||
ChatId(id)
|
ChatId(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A ChatID which indicates an error.
|
|
||||||
///
|
|
||||||
/// This is transitional and should not be used in new code. Do
|
|
||||||
/// not represent errors in a ChatId.
|
|
||||||
pub fn is_error(self) -> bool {
|
|
||||||
self.0 == 0
|
|
||||||
}
|
|
||||||
|
|
||||||
/// An unset ChatId
|
/// An unset ChatId
|
||||||
///
|
///
|
||||||
/// Like [ChatId::is_error], from which it is indistinguishable, this is
|
/// This is transitional and should not be used in new code.
|
||||||
/// transitional and should not be used in new code.
|
|
||||||
pub fn is_unset(self) -> bool {
|
pub fn is_unset(self) -> bool {
|
||||||
self.0 == 0
|
self.0 == 0
|
||||||
}
|
}
|
||||||
@@ -1930,8 +1921,8 @@ pub async fn create_group_chat(
|
|||||||
.sql
|
.sql
|
||||||
.get_rowid(context, "chats", "grpid", grpid)
|
.get_rowid(context, "chats", "grpid", grpid)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let chat_id = ChatId::new(row_id);
|
let chat_id = ChatId::new(row_id);
|
||||||
if !chat_id.is_error() {
|
|
||||||
if add_to_chat_contacts_table(context, chat_id, DC_CONTACT_ID_SELF).await {
|
if add_to_chat_contacts_table(context, chat_id, DC_CONTACT_ID_SELF).await {
|
||||||
let mut draft_msg = Message::new(Viewtype::Text);
|
let mut draft_msg = Message::new(Viewtype::Text);
|
||||||
draft_msg.set_text(Some(draft_txt));
|
draft_msg.set_text(Some(draft_txt));
|
||||||
@@ -1942,7 +1933,6 @@ pub async fn create_group_chat(
|
|||||||
msg_id: MsgId::new(0),
|
msg_id: MsgId::new(0),
|
||||||
chat_id: ChatId::new(0),
|
chat_id: ChatId::new(0),
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
Ok(chat_id)
|
Ok(chat_id)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user