base: Add BaseRoomInfo::room_version()

This commit is contained in:
Jonas Platte
2023-07-13 15:57:28 +02:00
committed by Jonas Platte
parent 70421cff54
commit 8067319208
2 changed files with 7 additions and 6 deletions
+6 -5
View File
@@ -110,6 +110,11 @@ impl BaseRoomInfo {
)
}
/// Get the room version of this room.
pub fn room_version(&self) -> Option<&RoomVersionId> {
Some(&self.create.as_ref()?.as_original()?.content.room_version)
}
/// Handle a state event for this room and update our info accordingly.
///
/// Returns true if the event modified the info, false otherwise.
@@ -210,11 +215,7 @@ impl BaseRoomInfo {
}
pub fn handle_redaction(&mut self, event: &OriginalSyncRoomRedactionEvent) {
let room_version = self
.create
.as_ref()
.and_then(|ev| Some(ev.as_original()?.content.room_version.to_owned()))
.unwrap_or(RoomVersionId::V1);
let room_version = self.room_version().unwrap_or(&RoomVersionId::V1).to_owned();
// FIXME: Use let chains once available to get rid of unwrap()s
if self.avatar.has_event_id(&event.redacts) {
+1 -1
View File
@@ -935,7 +935,7 @@ impl RoomInfo {
/// Get the room version of this room.
pub fn room_version(&self) -> Option<&RoomVersionId> {
Some(&self.base_info.create.as_ref()?.as_original()?.content.room_version)
self.base_info.room_version()
}
/// Get the room type of this room.