From 83196d4cb5659c659a47b1e6657db004bb1fa7f1 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Wed, 3 Apr 2024 18:20:13 +0200 Subject: [PATCH] add get_summary_text_without_prefix() use get_summary_text_without_prefix() to get raw summaries without prefixes, this is needed for reaction summaries, where we also do not show the name, so we do not want to show "Forwarded" as well. --- src/summary.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/summary.rs b/src/summary.rs index 6d018c064..b3a90e74d 100644 --- a/src/summary.rs +++ b/src/summary.rs @@ -72,7 +72,7 @@ impl Summary { // there is a reaction newer than the latest message, show that. // sorting and therefore date is still the one of the last message, // the reaction is is more sth. that overlays temporarily. - let summary = reaction_msg.get_summary_text(context).await; + let summary = reaction_msg.get_summary_text_without_prefix(context).await; return Ok(Summary { prefix: None, text: msg_reacted(context, reaction_contact_id, &reaction, &summary).await, @@ -139,6 +139,17 @@ impl Summary { impl Message { /// Returns a summary text. async fn get_summary_text(&self, context: &Context) -> String { + let summary = self.get_summary_text_without_prefix(context).await; + + if self.is_forwarded() { + format!("{}: {}", stock_str::forwarded(context).await, summary) + } else { + summary + } + } + + /// Returns a summary text without "Forwarded:" prefix. + async fn get_summary_text_without_prefix(&self, context: &Context) -> String { let (emoji, type_name, type_file, append_text); match self.viewtype { Viewtype::Image => { @@ -249,12 +260,6 @@ impl Message { summary }; - let summary = if self.is_forwarded() { - format!("{}: {}", stock_str::forwarded(context).await, summary) - } else { - summary - }; - summary.split_whitespace().collect::>().join(" ") } }