mirror of
https://github.com/chatmail/core.git
synced 2026-05-17 05:46:30 +03:00
refactor: Use chat_id.get_timestamp() instead of duplicating its code (#6691)
This commit is contained in:
15
src/chat.rs
15
src/chat.rs
@@ -1080,7 +1080,8 @@ impl ChatId {
|
|||||||
.unwrap_or(0))
|
.unwrap_or(0))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns timestamp of the latest message in the chat.
|
/// Returns timestamp of the latest message in the chat,
|
||||||
|
/// including hidden messages or a draft if there is one.
|
||||||
pub(crate) async fn get_timestamp(self, context: &Context) -> Result<Option<i64>> {
|
pub(crate) async fn get_timestamp(self, context: &Context) -> Result<Option<i64>> {
|
||||||
let timestamp = context
|
let timestamp = context
|
||||||
.sql
|
.sql
|
||||||
@@ -4608,17 +4609,7 @@ pub async fn add_device_msg_with_importance(
|
|||||||
// makes sure, the added message is the last one,
|
// makes sure, the added message is the last one,
|
||||||
// even if the date is wrong (useful esp. when warning about bad dates)
|
// even if the date is wrong (useful esp. when warning about bad dates)
|
||||||
let mut timestamp_sort = timestamp_sent;
|
let mut timestamp_sort = timestamp_sent;
|
||||||
if let Some(last_msg_time) = context
|
if let Some(last_msg_time) = chat_id.get_timestamp(context).await? {
|
||||||
.sql
|
|
||||||
.query_get_value(
|
|
||||||
"SELECT MAX(timestamp)
|
|
||||||
FROM msgs
|
|
||||||
WHERE chat_id=?
|
|
||||||
HAVING COUNT(*) > 0",
|
|
||||||
(chat_id,),
|
|
||||||
)
|
|
||||||
.await?
|
|
||||||
{
|
|
||||||
if timestamp_sort <= last_msg_time {
|
if timestamp_sort <= last_msg_time {
|
||||||
timestamp_sort = last_msg_time + 1;
|
timestamp_sort = last_msg_time + 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user