refactor(base): Unify identical branches and erase empty branches
@@ -591,9 +591,7 @@ impl BaseClient {
/// Update the internal and cached state accordingly. Return the final Room.
pub async fn room_joined(&self, room_id: &RoomId) -> Result<Room> {
let room = self.store.get_or_create_room(room_id, RoomType::Joined).await;
- if room.room_type() == RoomType::Joined {
- Ok(room)
- } else {
+ if room.room_type() != RoomType::Joined {
let _sync_lock = self.sync_lock().read().await;
let mut room_info = room.clone_info();
@@ -604,19 +602,17 @@ impl BaseClient {
changes.add_room(room_info.clone());
self.store.save_changes(&changes).await?; // Update the store
room.update_summary(room_info); // Update the cached room handle
+ }
Ok(room)
}
- }
/// User has left a room.
///
/// Update the internal and cached state accordingly. Return the final Room.
pub async fn room_left(&self, room_id: &RoomId) -> Result<Room> {
let room = self.store.get_or_create_room(room_id, RoomType::Left).await;
- if room.room_type() == RoomType::Left {
- Ok(room)
- } else {
+ if room.room_type() != RoomType::Left {
let _sync_lock = self.sync_lock().read().await;
let mut room_info = room.clone_info();
@@ -627,10 +623,10 @@ impl BaseClient {
changes.add_room(room_info.clone());
self.store.save_changes(&changes).await?; // Update the store
room.update_summary(room_info); // Update the cached room handle
+ }
Ok(room)
}
- }
/// Get access to the store's sync lock.
pub fn sync_lock(&self) -> &RwLock<()> {
