Skip to content

Commit

Permalink
"full message view" not needed because of footers
Browse files Browse the repository at this point in the history
standard footers meanwhile go the "contact status",
so they are no longer a reason to trigger "full message view".

this was already discussed when the HTML view was introduced at #2125
however, forgotten to change when the "contact status" was added at #2218

this pr will result in a cleaner chat view
with less "Show Full Message..." buttons
and will also save some storage
(in fact, i came over that when reviewing #4129 )
  • Loading branch information
r10s committed Mar 12, 2023
1 parent 4d620af commit 6d63bdf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/receive_imf/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2085,9 +2085,11 @@ Original signature",
false,
)
.await?;
let one2one_chat_id = t.get_last_msg().await.chat_id;
let msg = t.get_last_msg().await;
let one2one_chat_id = msg.chat_id;
let bob = Contact::load_from_db(&t, bob_id).await?;
assert_eq!(bob.get_status(), "Original signature");
assert!(!msg.has_html());

receive_imf(
&t,
Expand Down
14 changes: 7 additions & 7 deletions src/simplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ pub(crate) struct SimplifiedText {
/// True if the message is forwarded.
pub is_forwarded: bool,

/// True if nonstandard footer was removed.
/// True if nonstandard footer was removed
/// or if the message contains quotes other than `top_quote`.
pub is_cut: bool,

/// Top quote, if any.
Expand All @@ -103,7 +104,6 @@ pub(crate) fn simplify(mut input: String, is_chat_message: bool) -> SimplifiedTe
let original_lines = &lines;
let (lines, footer_lines) = remove_message_footer(lines);
let footer = footer_lines.map(|footer_lines| render_message(footer_lines, false));
is_cut = is_cut || footer.is_some();

let text = if is_chat_message {
render_message(lines, false)
Expand Down Expand Up @@ -330,7 +330,7 @@ mod tests {
} = simplify(input, true);
assert_eq!(text, "Hi! How are you?\n\n---\n\nI am good.");
assert!(!is_forwarded);
assert!(is_cut);
assert!(!is_cut);
assert_eq!(
footer.unwrap(),
"Sent with my Delta Chat Messenger: https://delta.chat"
Expand Down Expand Up @@ -365,7 +365,7 @@ mod tests {

assert_eq!(text, "Forwarded message");
assert!(is_forwarded);
assert!(is_cut);
assert!(!is_cut);
assert_eq!(footer.unwrap(), "Signature goes here");
}

Expand Down Expand Up @@ -442,7 +442,7 @@ mod tests {
..
} = simplify(input, true);
assert_eq!(text, "text\n\n--\nno footer");
assert!(is_cut);
assert!(!is_cut);
assert_eq!(footer.unwrap(), "footer");

let input = "text\n\n--\ntreated as footer when unescaped".to_string();
Expand All @@ -453,7 +453,7 @@ mod tests {
..
} = simplify(input.clone(), true);
assert_eq!(text, "text"); // see remove_message_footer() for some explanations
assert!(is_cut);
assert!(!is_cut);
assert_eq!(footer.unwrap(), "treated as footer when unescaped");
let escaped = escape_message_footer_marks(&input);
let SimplifiedText {
Expand Down Expand Up @@ -495,7 +495,7 @@ mod tests {
..
} = simplify(input.clone(), true);
assert_eq!(text, ""); // see remove_message_footer() for some explanations
assert!(is_cut);
assert!(!is_cut);
assert_eq!(footer.unwrap(), "treated as footer when unescaped");

let escaped = escape_message_footer_marks(&input);
Expand Down

0 comments on commit 6d63bdf

Please sign in to comment.