Skip to content

Commit

Permalink
Expose created_at from SendHandle directly instead of unpacking
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Salinas authored and Daniel Salinas committed Dec 20, 2024
1 parent 1e6bfa3 commit 8d4a9e7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion crates/matrix-sdk-ui/src/timeline/event_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),

Expand Down
4 changes: 1 addition & 3 deletions crates/matrix-sdk-ui/src/timeline/event_item/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<SendHandle>,
/// The time that the event was created locally
pub created_at: Option<MilliSecondsSinceUnixEpoch>,
}

impl LocalEventTimelineItem {
Expand Down
5 changes: 4 additions & 1 deletion crates/matrix-sdk-ui/src/timeline/event_item/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MilliSecondsSinceUnixEpoch> {
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.
Expand Down

0 comments on commit 8d4a9e7

Please sign in to comment.