Remove get_summarytext_by_raw

Use `Summary.truncated_text()` instead.

Co-Authored-By: Floris Bruynooghe <flub@devork.be>
This commit is contained in:
link2xt
2021-10-09 10:39:44 +00:00
parent 49b07c1c6a
commit a3562c5940
5 changed files with 158 additions and 237 deletions

View File

@@ -30,7 +30,7 @@ use crate::mimeparser::{parse_message_id, FailureReport, SystemMessage};
use crate::param::{Param, Params};
use crate::pgp::split_armored_data;
use crate::stock_str;
use crate::summary::{get_summarytext_by_raw, Summary};
use crate::summary::Summary;
/// Message ID, including reserved IDs.
///
@@ -592,7 +592,7 @@ impl Message {
}
/// Returns message summary for display in the search results.
pub async fn get_summary(&mut self, context: &Context, chat: Option<&Chat>) -> Result<Summary> {
pub async fn get_summary(&self, context: &Context, chat: Option<&Chat>) -> Result<Summary> {
let chat_loaded: Chat;
let chat = if let Some(chat) = chat {
chat
@@ -616,18 +616,6 @@ impl Message {
Ok(Summary::new(context, self, chat, contact.as_ref()).await)
}
pub async fn get_summarytext(&self, context: &Context, approx_characters: usize) -> String {
get_summarytext_by_raw(
self.viewtype,
self.text.as_ref(),
self.is_forwarded(),
&self.param,
approx_characters,
context,
)
.await
}
// It's a little unfortunate that the UI has to first call dc_msg_get_override_sender_name() and then if it was NULL, call
// dc_contact_get_display_name() but this was the best solution:
// - We could load a Contact struct from the db here to call get_display_name() instead of returning None, but then we had a db
@@ -871,7 +859,11 @@ impl Message {
Param::Quote,
if text.is_empty() {
// Use summary, similar to "Image" to avoid sending empty quote.
quote.get_summarytext(context, 500).await
quote
.get_summary(context, None)
.await?
.truncated_text(500)
.to_string()
} else {
text
},