Skip to content
5 changes: 5 additions & 0 deletions resources/icons/zoom_in.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions resources/icons/zoom_out.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 0 additions & 4 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,6 @@ fn clear_all_app_state(cx: &mut Cx) {

impl AppMain for App {
fn handle_event(&mut self, cx: &mut Cx, event: &Event) {
// if let Event::WindowGeomChange(geom) = event {
// log!("App::handle_event(): Window geometry changed: {:?}", geom);
// }

if let Event::Shutdown = event {
let window_ref = self.ui.window(ids!(main_window));
if let Err(e) = persistence::save_window_state(window_ref, cx) {
Expand Down
10 changes: 8 additions & 2 deletions src/home/room_read_receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,14 @@ impl AvatarRow {
self.buttons.iter_mut().zip(receipts_map.iter().rev())
{
if !*drawn {
let (_, drawn_status) =
avatar_ref.set_avatar_and_get_username(cx, room_id, user_id, None, event_id);
let (_, drawn_status) = avatar_ref.set_avatar_and_get_username(
cx,
room_id,
user_id,
None,
event_id,
true,
);
*drawn = drawn_status;
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/home/room_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2907,6 +2907,7 @@ fn populate_message_view(
event_tl_item.sender(),
Some(event_tl_item.sender_profile()),
event_tl_item.event_id(),
true,
);

// Prepend a "* <username> " to the emote body, as suggested by the Matrix spec.
Expand Down Expand Up @@ -3195,6 +3196,7 @@ fn populate_message_view(
event_tl_item.sender(),
Some(event_tl_item.sender_profile()),
event_tl_item.event_id(),
true,
)
);
if is_notice {
Expand Down Expand Up @@ -3664,6 +3666,7 @@ fn draw_replied_to_message(
&replied_to_event.sender,
Some(&replied_to_event.sender_profile),
Some(in_reply_to_details.event_id.as_ref()),
true,
);

fully_drawn = is_avatar_fully_drawn;
Expand Down Expand Up @@ -3996,6 +3999,7 @@ fn populate_small_state_event(
event_tl_item.sender(),
Some(event_tl_item.sender_profile()),
event_tl_item.event_id(),
true,
);
// Draw the timestamp as part of the profile.
if let Some(dt) = unix_time_millis_to_datetime(event_tl_item.timestamp()) {
Expand Down
1 change: 1 addition & 0 deletions src/room/room_input_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ impl RoomInputBar {
replying_to.0.sender(),
Some(replying_to.0.sender_profile()),
replying_to.0.event_id(),
true,
);

replying_preview
Expand Down
54 changes: 37 additions & 17 deletions src/shared/avatar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ live_design! {
align: { x: 0.5, y: 0.5 }
// the text_view and img_view are overlaid on top of each other.
flow: Overlay,
cursor: Hand,

text_view = <View> {
visible: true,
Expand Down Expand Up @@ -94,16 +93,16 @@ live_design! {
pub struct Avatar {
#[deref] view: View,

/// Information about the user profile being shown in this Avatar.
/// If `Some`, this Avatar will respond to clicks/taps.
#[rust] info: Option<UserProfileAndRoomId>,
}

impl Widget for Avatar {
fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {
self.view.handle_event(cx, event, scope);

let Some(info) = self.info.clone() else {
return;
};
let Some(info) = self.info.clone() else { return };
let area = self.view.area();
let widget_uid = self.widget_uid();
match event.hits(cx, area) {
Expand Down Expand Up @@ -152,16 +151,19 @@ impl Avatar {
info: Option<AvatarTextInfo>,
username: T,
) {
self.info = info.map(|AvatarTextInfo { user_id, username, room_id }|
UserProfileAndRoomId {
if let Some(AvatarTextInfo { user_id, username, room_id }) = info {
self.info = Some(UserProfileAndRoomId {
user_profile: UserProfile {
user_id,
username,
avatar_state: AvatarState::Unknown,
},
room_id,
}
);
});
self.view.apply_over(cx, live!{ cursor: Hand });
} else {
self.view.apply_over(cx, live!{ cursor: Default });
}
self.set_text(cx, username.as_ref());

// Apply background color if provided
Expand Down Expand Up @@ -200,16 +202,19 @@ impl Avatar {
self.view(ids!(img_view)).set_visible(cx, true);
self.view(ids!(text_view)).set_visible(cx, false);

self.info = info.map(|AvatarImageInfo { user_id, username, room_id, img_data }|
UserProfileAndRoomId {
if let Some(AvatarImageInfo { user_id, username, room_id, img_data }) = info {
self.info = Some(UserProfileAndRoomId {
user_profile: UserProfile {
user_id,
username,
avatar_state: AvatarState::Loaded(img_data),
},
room_id,
}
);
});
self.view.apply_over(cx, live!{ cursor: Hand });
} else {
self.view.apply_over(cx, live!{ cursor: Default });
}
}
res
}
Expand Down Expand Up @@ -244,6 +249,8 @@ impl Avatar {
/// our user profile cache , then the `username` and `avatar` will be the user ID
/// and the first character of that user ID, respectively.
///
/// If `is_clickable` is `true`, this Avatar will respond to clicks.
///
/// ## Return
/// Returns a tuple of:
/// 1. The displayable username that should be used to populate the username field.
Expand All @@ -256,6 +263,7 @@ impl Avatar {
avatar_user_id: &UserId,
avatar_profile_opt: Option<&TimelineDetails<Profile>>,
event_id: Option<&EventId>,
is_clickable: bool,
) -> (String, bool) {
// Get the display name and avatar URL from the user's profile, if available,
// or if the profile isn't ready, fall back to querying our user profile cache.
Expand Down Expand Up @@ -330,12 +338,12 @@ impl Avatar {
.and_then(|data| {
self.show_image(
cx,
Some((
is_clickable.then(|| AvatarImageInfo::from((
avatar_user_id.to_owned(),
username_opt.clone(),
room_id.to_owned(),
data.clone()).into(),
),
data.clone()
))),
|cx, img| utils::load_png_or_jpg(&img, cx, &data),
)
.ok()
Expand All @@ -344,7 +352,11 @@ impl Avatar {
self.show_text(
cx,
None,
Some((avatar_user_id.to_owned(), username_opt, room_id.to_owned()).into()),
is_clickable.then(|| AvatarTextInfo::from((
avatar_user_id.to_owned(),
username_opt,
room_id.to_owned(),
))),
&username,
)
});
Expand Down Expand Up @@ -399,9 +411,17 @@ impl AvatarRef {
avatar_user_id: &UserId,
avatar_profile_opt: Option<&TimelineDetails<Profile>>,
event_id: Option<&EventId>,
is_clickable: bool,
) -> (String, bool) {
if let Some(mut inner) = self.borrow_mut() {
inner.set_avatar_and_get_username(cx, room_id, avatar_user_id, avatar_profile_opt, event_id)
inner.set_avatar_and_get_username(
cx,
room_id,
avatar_user_id,
avatar_profile_opt,
event_id,
is_clickable,
)
} else {
(avatar_user_id.to_string(), false)
}
Expand Down
Loading