refactor: replace calc_timestamps with calc_sort_timestamp

This commit is contained in:
Alexander Krotov
2020-06-12 00:42:25 +03:00
committed by holger krekel
parent 944f1ec005
commit e03246d105

View File

@@ -599,9 +599,9 @@ async fn add_parts(
}
// correct message_timestamp, it should not be used before,
// however, we cannot do this earlier as we need from_id to be set
let (sort_timestamp, new_sent_timestamp, rcvd_timestamp) =
calc_timestamps(context, *sent_timestamp, *chat_id, !seen).await;
*sent_timestamp = new_sent_timestamp;
let rcvd_timestamp = time();
let sort_timestamp = calc_sort_timestamp(context, *sent_timestamp, *chat_id, !seen).await;
*sent_timestamp = std::cmp::min(*sent_timestamp, rcvd_timestamp);
// unarchive chat
chat_id.unarchive(context).await?;
@@ -827,17 +827,12 @@ async fn save_locations(
}
}
async fn calc_timestamps(
async fn calc_sort_timestamp(
context: &Context,
message_timestamp: i64,
chat_id: ChatId,
is_fresh_msg: bool,
) -> (i64, i64, i64) {
let rcvd_timestamp = time();
let mut sent_timestamp = message_timestamp;
if sent_timestamp > rcvd_timestamp {
sent_timestamp = rcvd_timestamp
}
) -> i64 {
let mut sort_timestamp = message_timestamp;
// get newest non fresh message for this chat
@@ -863,7 +858,7 @@ async fn calc_timestamps(
sort_timestamp = dc_create_smeared_timestamp(context).await;
}
(sort_timestamp, sent_timestamp, rcvd_timestamp)
sort_timestamp
}
/// This function tries extracts the group-id from the message and returns the