chore(base): Store tombstone event's ID in BaseRoomInfo

This commit is contained in:
Jonas Platte
2022-05-02 16:35:33 +02:00
committed by Jonas Platte
parent f93baf7ed4
commit 4e16f79ad2
2 changed files with 8 additions and 4 deletions

View File

@@ -162,7 +162,7 @@ pub struct BaseRoomInfo {
/// The `m.room.name` of this room.
name: Option<MinimalStateEvent<RoomNameEventContent>>,
/// The `m.room.tombstone` event content of this room.
pub(crate) tombstone: Option<RoomTombstoneEventContent>,
tombstone: Option<MinimalStateEvent<RoomTombstoneEventContent>>,
/// The topic of this room.
pub(crate) topic: Option<String>,
}
@@ -220,7 +220,7 @@ impl BaseRoomInfo {
self.topic = t.as_original().map(|t| t.content.topic.clone());
}
AnySyncStateEvent::RoomTombstone(t) => {
self.tombstone = t.as_original().map(|t| t.content.clone());
self.tombstone = Some(t.into());
}
AnySyncStateEvent::RoomPowerLevels(p) => {
self.max_power_level = p
@@ -269,7 +269,7 @@ impl BaseRoomInfo {
self.topic = Some(t.content.topic.clone());
}
AnyStrippedStateEvent::RoomTombstone(t) => {
self.tombstone = Some(t.content.clone());
self.tombstone = Some(t.into());
}
AnyStrippedStateEvent::RoomPowerLevels(p) => {
self.max_power_level = p

View File

@@ -262,7 +262,7 @@ impl Room {
/// Get the `m.room.tombstone` content of this room if there is one.
pub fn tombstone(&self) -> Option<RoomTombstoneEventContent> {
self.inner.read().unwrap().base_info.tombstone.clone()
self.inner.read().unwrap().tombstone().cloned()
}
/// Get the topic of the room.
@@ -784,6 +784,10 @@ impl RoomInfo {
fn name(&self) -> Option<&str> {
Some(self.base_info.name.as_ref()?.as_original()?.content.name.as_ref()?.as_ref())
}
fn tombstone(&self) -> Option<&RoomTombstoneEventContent> {
Some(&self.base_info.tombstone.as_ref()?.as_original()?.content)
}
}
#[cfg(test)]