Add 'euph.rooms.<name>.autojoin' config option

This commit is contained in:
Joscha 2022-08-27 15:08:47 +02:00
parent 74561c791b
commit 04581f9158
3 changed files with 12 additions and 1 deletions

View file

@ -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<String>,
#[serde(default)]
pub force_username: bool,

View file

@ -57,7 +57,7 @@ impl Rooms {
vault: Vault,
ui_event_tx: mpsc::UnboundedSender<UiEvent>,
) -> 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 {