From b9d0aa9b54c17b86a802f44f07bdcc4ffdeb5468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Sun, 30 Jun 2024 14:55:35 +0200 Subject: [PATCH] ui: Expose content of RepliedToInfo and EditInfo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kévin Commaille --- crates/matrix-sdk-ui/src/timeline/mod.rs | 27 ++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/crates/matrix-sdk-ui/src/timeline/mod.rs b/crates/matrix-sdk-ui/src/timeline/mod.rs index 8a00344a7..ffc38893f 100644 --- a/crates/matrix-sdk-ui/src/timeline/mod.rs +++ b/crates/matrix-sdk-ui/src/timeline/mod.rs @@ -109,7 +109,7 @@ use self::{ }; /// Information needed to edit an event. -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct EditInfo { /// The event ID of the event that needs editing. id: EventItemIdentifier, @@ -117,6 +117,13 @@ pub struct EditInfo { original_message: Message, } +impl EditInfo { + /// The original content of the event that needs editing. + pub fn original_message(&self) -> &Message { + &self.original_message + } +} + /// Information needed to reply to an event. #[derive(Debug)] pub struct RepliedToInfo { @@ -130,12 +137,24 @@ pub struct RepliedToInfo { content: ReplyContent, } +impl RepliedToInfo { + /// The sender of the event to reply to. + pub fn sender(&self) -> &UserId { + &self.sender + } + + /// The content of the event to reply to. + pub fn content(&self) -> &ReplyContent { + &self.content + } +} + /// The content of a reply. -#[derive(Debug)] -enum ReplyContent { +#[derive(Debug, Clone)] +pub enum ReplyContent { /// Content of a message event. Message(Message), - /// Content of any other kind of event stored as raw. + /// Content of any other kind of event stored as raw JSON. Raw(Raw), }