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.
This commit is contained in:
Joscha 2024-01-03 18:24:17 +01:00
parent 2d2dab11ba
commit 88ba77b955
3 changed files with 15 additions and 11 deletions

0
cove-config/CONFIG.md Normal file
View file

View file

@ -287,7 +287,8 @@ impl EuphRoom {
async fn status_widget(&self, state: Option<&euph::State>) -> impl Widget<UiError> {
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

View file

@ -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)
});