From 88ba77b95575ed2cd3396813eefb9b497421714e Mon Sep 17 00:00:00 2001 From: Joscha Date: Wed, 3 Jan 2024 18:24:17 +0100 Subject: [PATCH] Move domains in front of room names in the UI The reasoning behind this change in the room list is that putting the domain (which rarely changes) in front of the room name (which often changes) is a lot more readable. It also moves it away from the status info parentheses, making them more obvious again. The reasoning for the individual room view is consistency. Putting the domain at the end here looked fine, but putting it in front matches the room list and still looks fine. --- cove-config/CONFIG.md | 0 cove/src/ui/euph/room.rs | 5 ++--- cove/src/ui/rooms.rs | 21 +++++++++++++-------- 3 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 cove-config/CONFIG.md diff --git a/cove-config/CONFIG.md b/cove-config/CONFIG.md new file mode 100644 index 0000000..e69de29 diff --git a/cove/src/ui/euph/room.rs b/cove/src/ui/euph/room.rs index c1c4fec..b226b75 100644 --- a/cove/src/ui/euph/room.rs +++ b/cove/src/ui/euph/room.rs @@ -287,7 +287,8 @@ impl EuphRoom { async fn status_widget(&self, state: Option<&euph::State>) -> impl Widget { let room_style = Style::new().bold().blue(); - let mut info = Styled::new(format!("&{}", self.name()), room_style); + let mut info = Styled::new(format!("{} ", self.domain()), Style::new().grey()) + .then(format!("&{}", self.name()), room_style); info = match state { None | Some(euph::State::Stopped) => info.then_plain(", archive"), @@ -310,8 +311,6 @@ impl EuphRoom { } }; - info = info.then(format!(" - {}", self.domain()), Style::new().grey()); - let unseen = self.unseen_msgs_count().await; if unseen > 0 { info = info diff --git a/cove/src/ui/rooms.rs b/cove/src/ui/rooms.rs index 48e3ad3..4275b48 100644 --- a/cove/src/ui/rooms.rs +++ b/cove/src/ui/rooms.rs @@ -356,10 +356,9 @@ impl Rooms { fn sort_rooms(rooms: &mut [(&RoomIdentifier, Option<&euph::State>, usize)], order: Order) { match order { - Order::Alphabet => rooms.sort_unstable_by_key(|(id, _, _)| (&id.name, &id.domain)), - Order::Importance => rooms.sort_unstable_by_key(|(id, state, unseen)| { - (state.is_none(), *unseen == 0, &id.name, &id.domain) - }), + Order::Alphabet => rooms.sort_unstable_by_key(|(id, _, _)| *id), + Order::Importance => rooms + .sort_unstable_by_key(|(id, state, unseen)| (state.is_none(), *unseen == 0, *id)), } } @@ -379,15 +378,21 @@ impl Rooms { let id = id.clone(); let info = Self::format_room_info(state, unseen); list_builder.add_sel(id.clone(), move |selected| { - let style = if selected { + let domain_style = if selected { + Style::new().black().on_white() + } else { + Style::new().grey() + }; + + let room_style = if selected { Style::new().bold().black().on_white() } else { Style::new().bold().blue() }; - let text = Styled::new(format!("&{}", id.name), style) - .and_then(info) - .then(format!(" - {}", id.domain), Style::new().grey()); + let text = Styled::new(format!("{} ", id.domain), domain_style) + .then(format!("&{}", id.name), room_style) + .and_then(info); Text::new(text) });