Add rooms keybindings around autojoin rooms

This commit is contained in:
Joscha 2022-08-30 15:09:06 +02:00
parent a091855ea3
commit 03ddc5eb9b
2 changed files with 24 additions and 0 deletions

View file

@ -25,6 +25,7 @@ Procedure when bumping the version number:
- `euph.rooms.<name>.password` config option
- Key binding to change rooms sort order
- Key bindings to connect to/disconnect from all rooms
- Key bindings to connect to autojoin rooms/disconnect from non-autojoin rooms
- Key bindings to move to parent/root message
- Key bindings to view and open links in a message

View file

@ -295,6 +295,8 @@ impl Rooms {
bindings.binding("C", "connect to all rooms");
bindings.binding("d", "disconnect from selected room");
bindings.binding("D", "disconnect from all rooms");
bindings.binding("a", "connect to all autojoin room");
bindings.binding("A", "disconnect from all non-autojoin rooms");
bindings.binding("n", "connect to new room");
bindings.binding("X", "delete room");
bindings.empty();
@ -369,6 +371,27 @@ impl Rooms {
room.disconnect();
}
}
key!('a') => {
for (name, options) in &self.config.euph.rooms {
if options.autojoin {
self.get_or_insert_room(name.clone()).connect();
}
}
}
key!('A') => {
for (name, room) in &mut self.euph_rooms {
let autojoin = self
.config
.euph
.rooms
.get(name)
.map(|r| r.autojoin)
.unwrap_or(false);
if !autojoin {
room.disconnect();
}
}
}
key!('n') => self.state = State::Connect(EditorState::new()),
key!('X') => {
// TODO Check whether user wanted this via popup