Add 'euph.rooms.<name>.autojoin' config option
This commit is contained in:
parent
74561c791b
commit
04581f9158
3 changed files with 12 additions and 1 deletions
|
|
@ -18,6 +18,7 @@ Procedure when bumping the version number:
|
||||||
- Config file
|
- Config file
|
||||||
- `ephemeral` config option
|
- `ephemeral` config option
|
||||||
- `data_dir` config option
|
- `data_dir` config option
|
||||||
|
- `euph.rooms.<name>.autojoin` config option
|
||||||
- `euph.rooms.<name>.username` config option
|
- `euph.rooms.<name>.username` config option
|
||||||
- `euph.rooms.<name>.force_username` config option
|
- `euph.rooms.<name>.force_username` config option
|
||||||
- `euph.rooms.<name>.password` config option
|
- `euph.rooms.<name>.password` config option
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ use crate::macros::ok_or_return;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, Deserialize)]
|
#[derive(Debug, Clone, Default, Deserialize)]
|
||||||
pub struct EuphRoom {
|
pub struct EuphRoom {
|
||||||
|
#[serde(default)]
|
||||||
|
pub autojoin: bool,
|
||||||
pub username: Option<String>,
|
pub username: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub force_username: bool,
|
pub force_username: bool,
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ impl Rooms {
|
||||||
vault: Vault,
|
vault: Vault,
|
||||||
ui_event_tx: mpsc::UnboundedSender<UiEvent>,
|
ui_event_tx: mpsc::UnboundedSender<UiEvent>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
let mut result = Self {
|
||||||
config,
|
config,
|
||||||
vault,
|
vault,
|
||||||
ui_event_tx,
|
ui_event_tx,
|
||||||
|
|
@ -65,7 +65,15 @@ impl Rooms {
|
||||||
list: ListState::new(),
|
list: ListState::new(),
|
||||||
order: Order::Alphabet,
|
order: Order::Alphabet,
|
||||||
euph_rooms: HashMap::new(),
|
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 {
|
fn get_or_insert_room(&mut self, name: String) -> &mut EuphRoom {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue