From 8d4a9e7e7e69287568ce5b2b4cc8b8f3fa3f90a6 Mon Sep 17 00:00:00 2001 From: Daniel Salinas Date: Fri, 20 Dec 2024 09:26:31 -0600 Subject: [PATCH] Expose created_at from SendHandle directly instead of unpacking --- crates/matrix-sdk-ui/src/timeline/event_handler.rs | 1 - crates/matrix-sdk-ui/src/timeline/event_item/local.rs | 4 +--- crates/matrix-sdk-ui/src/timeline/event_item/mod.rs | 5 ++++- 3 files changed, 5 insertions(+), 5 deletions(-) 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..1ef7ba22329 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.