From 923e68c0b59d050ade0e396b0a88fb6bdb5d1659 Mon Sep 17 00:00:00 2001 From: Joscha Date: Mon, 29 Aug 2022 20:13:47 +0200 Subject: [PATCH] Always show rooms from config in rooms list --- CHANGELOG.md | 1 + src/ui/rooms.rs | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51e2088..c9d4acc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Procedure when bumping the version number: ### Changed - Improved JSON export performance +- Always show rooms from config file in room list ### Fixed - Rooms reconnecting instead of showing error popups diff --git a/src/ui/rooms.rs b/src/ui/rooms.rs index eac0a75..be59196 100644 --- a/src/ui/rooms.rs +++ b/src/ui/rooms.rs @@ -138,22 +138,30 @@ impl Rooms { } } - /// Remove rooms that are not running any more and can't be found in the db. - /// Insert rooms that are in the db but not yet in in the hash map. + /// Remove rooms that are not running any more and can't be found in the db + /// or config. Insert rooms that are in the db or config but not yet in in + /// the hash map. /// /// These kinds of rooms are either /// - failed connection attempts, or /// - rooms that were deleted from the db. async fn stabilize_rooms(&mut self) { + // Collect all rooms from the db and config file let rooms = logging_unwrap!(self.vault.euph().rooms().await); - let mut rooms_set = rooms.into_iter().collect::>(); + let mut rooms_set = rooms + .into_iter() + .chain(self.config.euph.rooms.keys().cloned()) + .collect::>(); // Prevent room that is currently being shown from being removed. This - // could otherwise happen when connecting to a room that doesn't exist. + // could otherwise happen after connecting to a room that doesn't exist. if let State::ShowRoom(name) = &self.state { rooms_set.insert(name.clone()); } + // Now `rooms_set` contains all rooms that must exist. Other rooms may + // also exist, for example rooms that are connecting for the first time. + self.euph_rooms .retain(|n, r| !r.stopped() || rooms_set.contains(n));