Make initial rooms sort order configurable
This commit is contained in:
parent
61a9cc10f1
commit
7dfa8c6048
4 changed files with 38 additions and 2 deletions
|
|
@ -20,6 +20,7 @@ Procedure when bumping the version number:
|
||||||
- Message inspection popup
|
- Message inspection popup
|
||||||
- Session inspection popup
|
- Session inspection popup
|
||||||
- Error popup when external editor fails
|
- Error popup when external editor fails
|
||||||
|
- `rooms_sort_order` config option
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Use nick changes to detect sessions for nick list
|
- Use nick changes to detect sessions for nick list
|
||||||
|
|
|
||||||
16
README.md
16
README.md
|
|
@ -115,6 +115,22 @@ the rooms list.
|
||||||
|
|
||||||
See also the `--offline` command line option.
|
See also the `--offline` command line option.
|
||||||
|
|
||||||
|
### `rooms_sort_order`
|
||||||
|
|
||||||
|
**Type:** String, one of `alphabetic`, `importance`
|
||||||
|
**Default:** `alphabetic`
|
||||||
|
|
||||||
|
Initial sort order of rooms list.
|
||||||
|
|
||||||
|
`alphabetic` sorts rooms in alphabetic order.
|
||||||
|
|
||||||
|
`importance` sorts rooms by the following criteria (in descending order of
|
||||||
|
priority):
|
||||||
|
|
||||||
|
1. connected rooms before unconnected rooms
|
||||||
|
2. rooms with unread messages before rooms without
|
||||||
|
3. alphabetic order
|
||||||
|
|
||||||
### `euph.rooms.<room>.autojoin`
|
### `euph.rooms.<room>.autojoin`
|
||||||
|
|
||||||
**Type:** Boolean
|
**Type:** Boolean
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,14 @@ use serde::Deserialize;
|
||||||
|
|
||||||
use crate::macros::ok_or_return;
|
use crate::macros::ok_or_return;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, Default, Deserialize)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub enum RoomsSortOrder {
|
||||||
|
#[default]
|
||||||
|
Alphabet,
|
||||||
|
Importance,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, Deserialize)]
|
#[derive(Debug, Clone, Default, Deserialize)]
|
||||||
pub struct EuphRoom {
|
pub struct EuphRoom {
|
||||||
// TODO Mark favourite rooms via printable ascii characters
|
// TODO Mark favourite rooms via printable ascii characters
|
||||||
|
|
@ -29,6 +37,8 @@ pub struct Config {
|
||||||
pub ephemeral: bool,
|
pub ephemeral: bool,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub offline: bool,
|
pub offline: bool,
|
||||||
|
#[serde(default)]
|
||||||
|
pub rooms_sort_order: RoomsSortOrder,
|
||||||
// TODO Invoke external notification command?
|
// TODO Invoke external notification command?
|
||||||
pub euph: Euph,
|
pub euph: Euph,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use tokio::sync::mpsc;
|
||||||
use toss::styled::Styled;
|
use toss::styled::Styled;
|
||||||
use toss::terminal::Terminal;
|
use toss::terminal::Terminal;
|
||||||
|
|
||||||
use crate::config::Config;
|
use crate::config::{Config, RoomsSortOrder};
|
||||||
use crate::euph::EuphRoomEvent;
|
use crate::euph::EuphRoomEvent;
|
||||||
use crate::vault::Vault;
|
use crate::vault::Vault;
|
||||||
|
|
||||||
|
|
@ -38,6 +38,15 @@ enum Order {
|
||||||
Importance,
|
Importance,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Order {
|
||||||
|
fn from_rooms_sort_order(order: RoomsSortOrder) -> Self {
|
||||||
|
match order {
|
||||||
|
RoomsSortOrder::Alphabet => Self::Alphabet,
|
||||||
|
RoomsSortOrder::Importance => Self::Importance,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Rooms {
|
pub struct Rooms {
|
||||||
config: &'static Config,
|
config: &'static Config,
|
||||||
|
|
||||||
|
|
@ -63,7 +72,7 @@ impl Rooms {
|
||||||
ui_event_tx,
|
ui_event_tx,
|
||||||
state: State::ShowList,
|
state: State::ShowList,
|
||||||
list: ListState::new(),
|
list: ListState::new(),
|
||||||
order: Order::Alphabet,
|
order: Order::from_rooms_sort_order(config.rooms_sort_order),
|
||||||
euph_rooms: HashMap::new(),
|
euph_rooms: HashMap::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue