summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoscha <joscha@plugh.de>2022-08-30 15:09:06 +0200
committerJoscha <joscha@plugh.de>2022-08-30 15:09:06 +0200
commit03ddc5eb9badfdbd373ae9da2ab7663940f072e9 (patch)
tree6a3eb84b98afbd75cabef599751b205078e6c789
parenta091855ea3ee0c6d39fff8b5803820c31c43fef3 (diff)
Add rooms keybindings around autojoin rooms
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/ui/rooms.rs23
2 files changed, 24 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5efac14..d341486 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/src/ui/rooms.rs b/src/ui/rooms.rs
index 54ef872..0cb77c4 100644
--- a/src/ui/rooms.rs
+++ b/src/ui/rooms.rs
@@ -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