Skip to content

Commit

Permalink
Highlights buffer now includes Action messages
Browse files Browse the repository at this point in the history
  • Loading branch information
englut committed Dec 16, 2024
1 parent 1c5dad6 commit f0c6e33
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
1 change: 0 additions & 1 deletion data/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,6 @@ fn text_references_nickname(text: &str, nickname: NickRef) -> Option<bool> {

fn parse_user_and_channel_fragments(text: &str, channel_users: &[User]) -> Vec<Fragment> {
text.chars()
.filter(|&c| c != '\u{1}')
.group_by(|c| c.is_whitespace())
.into_iter()
.flat_map(|(is_whitespace, chars)| {
Expand Down
45 changes: 44 additions & 1 deletion src/buffer/highlights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,50 @@ pub fn view<'a>(
)
.into(),
)
}
},
message::Target::Highlights {
server,
channel,
source: message::Source::Action(_),
} => {
let timestamp =
config
.buffer
.format_timestamp(&message.server_time)
.map(|timestamp| {
selectable_text(timestamp).style(theme::selectable_text::timestamp)
});

let channel_text = selectable_rich_text::<_, _, (), _, _>(vec![
span(channel.as_str())
.color(theme.colors().buffer.url)
.link(message::Link::GoToMessage(
server.clone(),
channel.clone(),
message.hash,
)),
span(" "),
])
.on_link(scroll_view::Message::Link);

let text = message_content(
&message.content,
theme,
scroll_view::Message::Link,
theme::selectable_text::action,
config,
);

Some(
container(
row![]
.push_maybe(timestamp)
.push(channel_text)
.push(text),
)
.into(),
)
},
_ => None,
},
)
Expand Down

0 comments on commit f0c6e33

Please sign in to comment.