renew: stage 6 #29

Open
opened 2026-04-30 12:29:02 +02:00 by kir68k · 0 comments
Owner

Focus: Main/Home screen (TUI)

Notes

As said in a previous issue, I like where I was going with the gui layout.

It contained a sidebar, which acted as a list with cards for each joined room/dm.
The cards had a display name, and the last message, akin to actual IM clients like element on mobile or disc*rd.

Avatar can be skipped/replaced with placeholder square with initials of the display name, or I could look at using the terminal image protocols.

The room data was cached in a HashMap<OwnedRoomId, RoomData>.

Relevant stuff from #19

Last message enum:

Lines 44 to 54 in 401b91e
/// Last received message event in a room
#[derive(Clone, Debug, PartialEq)]
pub enum LastMessage {
Text(SharedString),
Image,
Video,
Audio,
File(SharedString), // filename
Unknown,
None,
}

Room info for the UI:

Lines 70 to 76 in 401b91e
/// Holds UI-relevant room data to display as a card or on the sidebar
#[derive(Clone, Debug, Default, PartialEq)]
pub struct RoomData {
pub display_name: Option<SharedString>,
pub avatar: Option<Arc<gpui::Image>>,
pub last_msg: Option<LastMessage>,
}

Getting the last message:

Lines 362 to 368 in 401b91e
let last_msg = last_event.and_then(|event| {
use matrix_sdk::ruma::events::{
AnySyncMessageLikeEvent, AnySyncTimelineEvent,
room::message::{MessageType, SyncRoomMessageEvent},
};
// only handle stuff that can be displayed in ui


(see L362-387 for full expr)

Getting the room avatar to render:

Lines 317 to 329 in 401b91e
// Thumbnail = less memory (relatively anyway), less unneeded network I/O
// also renders much nicer, downscaling a full file in the app makes it veeeeeery aliased >_<
let avatar = if not_rate_limited {
tracing::debug!(
"Not rate limited, downloading {:?} ({:?})",
&display_name,
&room_id
);
// FIXME: i don't know why but *some* rooms simply refuse to return an avatar
room.avatar(matrix_sdk::media::MediaFormat::Thumbnail(
MediaThumbnailSettings::with_method(ruma::media::Method::Crop, 96u32.into(), 96u32.into()),
))


(see L317-L356 for the full expr)

Note that the last message/avatar expressions would just be their own functions, probably, if ported. The linked snippets are a part of the function

pub fn get_room_data(&mut self, room: Room, cx: &mut Context<Self>) {

**Focus**: Main/Home screen (TUI) ### Notes As said in a previous issue, I like where I was going with the gui *layout*. It contained a sidebar, which acted as a list with cards for each joined room/dm. The cards had a display name, and the last message, akin to actual IM clients like element on mobile or disc*rd. Avatar can be skipped/replaced with placeholder square with initials of the display name, *or* I could look at using the terminal image protocols. The room data was cached in a `HashMap<OwnedRoomId, RoomData>`. ### Relevant stuff from #19 Last message enum: https://l2.stylism.moe/kir68k/lattice/src/commit/401b91e21642dff891ef448621acab66f1c0a8ac/src/ui/mod.rs#L44-L54 Room info for the UI: https://l2.stylism.moe/kir68k/lattice/src/commit/401b91e21642dff891ef448621acab66f1c0a8ac/src/ui/mod.rs#L70-L76 Getting the last message: https://l2.stylism.moe/kir68k/lattice/src/commit/401b91e21642dff891ef448621acab66f1c0a8ac/src/ui/mod.rs#L362-L368 (see L362-387 for full expr) Getting the room avatar to render: https://l2.stylism.moe/kir68k/lattice/src/commit/401b91e21642dff891ef448621acab66f1c0a8ac/src/ui/mod.rs#L317-L329 (see L317-L356 for the full expr) Note that the last message/avatar expressions would just be their own functions, probably, if ported. The linked snippets are a part of the function https://l2.stylism.moe/kir68k/lattice/src/commit/401b91e21642dff891ef448621acab66f1c0a8ac/src/ui/mod.rs#L302
kir68k added this to the a new start project 2026-04-30 12:29:02 +02:00
Sign in to join this conversation.
No description provided.