Fix crash when connecting to some types of room

This commit is contained in:
Joscha 2022-08-17 23:04:43 +02:00
parent 34bcf85236
commit 80dad00125
2 changed files with 12 additions and 1 deletions

View file

@ -14,6 +14,10 @@ Procedure when bumping the version number:
## Unreleased
### Fixed
- Crash when connecting to nonexistent rooms
- Crash when connecting to rooms that require authentication
## v0.2.1 - 2022-08-11
### Added

View file

@ -67,12 +67,19 @@ impl Rooms {
/// - failed connection attempts, or
/// - rooms that were deleted from the db.
async fn stabilize_rooms(&mut self) {
let rooms_set = self
let mut rooms_set = self
.vault
.euph_rooms()
.await
.into_iter()
.collect::<HashSet<_>>();
// Prevent room that is currently being shown from being removed. This
// could otherwise happen when connecting to a room that doesn't exist.
if let State::ShowRoom(name) = &self.state {
rooms_set.insert(name.clone());
}
self.euph_rooms
.retain(|n, r| !r.stopped() || rooms_set.contains(n));