Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/chat/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ pub trait Message: Clone {
pub trait MessageAuthor: PartialEq + Eq {
fn get_display_name(&self) -> impl Element;
fn get_icon(&self) -> String;
fn get_small_icon(&self) -> String;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im just wondering if another routine is really the correct way to go about this? Main questions I would ask are:

  1. Do we ever need to get a large icon for a message author?
    If so,
  2. Do we ever need to get anything other than a "normal" and "small" icon?

if 1 is no, Then I wouldn't add a new method and would just have the normal get_icon method return a 32px image.

If 1 is yes, then I think the better route would be an argument to get_icon.

If 2 is no, then that argument could be as simple as an enum IconSize

if 2 is yes, then that argument maybe should be something like a IconFormat config

fn get_id(&self) -> String;
}
4 changes: 4 additions & 0 deletions src/discord/src/message/author.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ impl MessageAuthor for DiscordMessageAuthor {
self.icon.clone()
}

fn get_small_icon(&self) -> String {
self.icon.clone() + "?size=32"
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one of my plans is to have get_icon return an Element. This way, discord for example, can display user icon decorations without us having to make an entire Chat interface for "decoration"

fn get_id(&self) -> String {
self.id.clone()
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/src/channel/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn message<M: Message>(message: MessageGroup<M>) -> impl IntoElement {
.text_color(rgb(0xFFFFFF))
.gap_4()
.pb_6()
.child(img(message.get_author().get_icon()).flex_shrink_0().object_fit(gpui::ObjectFit::Fill).bg(rgb(0xFFFFFF)).rounded_full().w_12().h_12())
.child(img(message.get_author().get_small_icon()).flex_shrink_0().object_fit(gpui::ObjectFit::Fill).rounded_full().w_12().h_12())
.child(
div()
.flex()
Expand Down