renew: stage 6 #29
Labels
No labels
bug
critical
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Reference
kir68k/lattice#29
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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:
/// Last received message event in a room#[derive(Clone, Debug, PartialEq)]pub enum LastMessage {Text(SharedString),Image,Video,Audio,File(SharedString), // filenameUnknown,None,}Room info for the UI:
/// 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:
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:
// 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 avatarroom.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>) {