diff --git a/CHANGELOG.md b/CHANGELOG.md index d96a5f4..d6a4e10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Procedure when bumping the version number: - Config file - `ephemeral` config option - `data_dir` config option +- `euph.rooms..autojoin` config option - `euph.rooms..username` config option - `euph.rooms..force_username` config option - `euph.rooms..password` config option diff --git a/src/config.rs b/src/config.rs index 9ab0d27..dedfe21 100644 --- a/src/config.rs +++ b/src/config.rs @@ -8,6 +8,8 @@ use crate::macros::ok_or_return; #[derive(Debug, Clone, Default, Deserialize)] pub struct EuphRoom { + #[serde(default)] + pub autojoin: bool, pub username: Option, #[serde(default)] pub force_username: bool, diff --git a/src/ui/rooms.rs b/src/ui/rooms.rs index 7ac88d3..91c1a43 100644 --- a/src/ui/rooms.rs +++ b/src/ui/rooms.rs @@ -57,7 +57,7 @@ impl Rooms { vault: Vault, ui_event_tx: mpsc::UnboundedSender, ) -> Self { - Self { + let mut result = Self { config, vault, ui_event_tx, @@ -65,7 +65,15 @@ impl Rooms { list: ListState::new(), order: Order::Alphabet, euph_rooms: HashMap::new(), + }; + + for (name, config) in &config.euph.rooms { + if config.autojoin { + result.get_or_insert_room(name.clone()).connect(); + } } + + result } fn get_or_insert_room(&mut self, name: String) -> &mut EuphRoom {