diff --git a/crates/matrix-sdk-sqlite/src/state_store.rs b/crates/matrix-sdk-sqlite/src/state_store.rs index abf2fcb2300..8df4e75fcc8 100644 --- a/crates/matrix-sdk-sqlite/src/state_store.rs +++ b/crates/matrix-sdk-sqlite/src/state_store.rs @@ -1863,7 +1863,7 @@ impl StateStore for SqliteStateStore { let mut requests = Vec::with_capacity(res.len()); for entry in res { let created_at = UInt::new(entry.4) - .map_or_else(|| MilliSecondsSinceUnixEpoch::now(), MilliSecondsSinceUnixEpoch); + .map_or_else(MilliSecondsSinceUnixEpoch::now, MilliSecondsSinceUnixEpoch); requests.push(QueuedRequest { transaction_id: entry.0.into(), kind: self.deserialize_json(&entry.1)?, @@ -2061,7 +2061,7 @@ impl StateStore for SqliteStateStore { let mut dependent_events = Vec::with_capacity(res.len()); for entry in res { let created_at = UInt::new(entry.4) - .map_or_else(|| MilliSecondsSinceUnixEpoch::now(), MilliSecondsSinceUnixEpoch); + .map_or_else(MilliSecondsSinceUnixEpoch::now, MilliSecondsSinceUnixEpoch); dependent_events.push(DependentQueuedRequest { own_transaction_id: entry.0.into(), parent_transaction_id: entry.1.into(), diff --git a/crates/matrix-sdk-ui/src/timeline/event_handler.rs b/crates/matrix-sdk-ui/src/timeline/event_handler.rs index a67467ae266..475c1f30a14 100644 --- a/crates/matrix-sdk-ui/src/timeline/event_handler.rs +++ b/crates/matrix-sdk-ui/src/timeline/event_handler.rs @@ -1033,7 +1033,6 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> { send_state: EventSendState::NotSentYet, transaction_id: txn_id.to_owned(), send_handle: send_handle.clone(), - created_at: send_handle.clone().map(|h| h.created_at), } .into(), diff --git a/crates/matrix-sdk-ui/src/timeline/event_item/local.rs b/crates/matrix-sdk-ui/src/timeline/event_item/local.rs index 3f5cd48c953..2890b6eab8e 100644 --- a/crates/matrix-sdk-ui/src/timeline/event_item/local.rs +++ b/crates/matrix-sdk-ui/src/timeline/event_item/local.rs @@ -16,7 +16,7 @@ use std::sync::Arc; use as_variant::as_variant; use matrix_sdk::{send_queue::SendHandle, Error}; -use ruma::{EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedTransactionId}; +use ruma::{EventId, OwnedEventId, OwnedTransactionId}; use super::TimelineEventItemId; @@ -30,8 +30,6 @@ pub(in crate::timeline) struct LocalEventTimelineItem { pub transaction_id: OwnedTransactionId, /// A handle to manipulate this event before it is sent, if possible. pub send_handle: Option, - /// The time that the event was created locally - pub created_at: Option, } impl LocalEventTimelineItem { diff --git a/crates/matrix-sdk-ui/src/timeline/event_item/mod.rs b/crates/matrix-sdk-ui/src/timeline/event_item/mod.rs index 607f3efcfe0..47918eba1e1 100644 --- a/crates/matrix-sdk-ui/src/timeline/event_item/mod.rs +++ b/crates/matrix-sdk-ui/src/timeline/event_item/mod.rs @@ -270,7 +270,10 @@ impl EventTimelineItem { /// Get the time that the local event was pushed in the send queue at. pub fn local_created_at(&self) -> Option { - as_variant!(&self.kind, EventTimelineItemKind::Local(local) => local.created_at).flatten() + match &self.kind { + EventTimelineItemKind::Local(local) => local.send_handle.as_ref().map(|s| s.created_at), + EventTimelineItemKind::Remote(_) => None, + } } /// Get the unique identifier of this item.