From d06371d458a3f6980354f87dc82fca1cc6c3cffc Mon Sep 17 00:00:00 2001 From: Amanda Graven Date: Wed, 27 Oct 2021 10:39:19 +0200 Subject: [PATCH] Add convenience function to check if a room is a space --- crates/matrix-sdk-base/src/rooms/normal.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/matrix-sdk-base/src/rooms/normal.rs b/crates/matrix-sdk-base/src/rooms/normal.rs index 731dfd220..bdbb9fc81 100644 --- a/crates/matrix-sdk-base/src/rooms/normal.rs +++ b/crates/matrix-sdk-base/src/rooms/normal.rs @@ -26,8 +26,11 @@ use ruma::{ events::{ receipt::Receipt, room::{ - create::CreateEventContent, encryption::EncryptionEventContent, - guest_access::GuestAccess, history_visibility::HistoryVisibility, join_rules::JoinRule, + create::{CreateEventContent, RoomType as CreateRoomType}, + encryption::EncryptionEventContent, + guest_access::GuestAccess, + history_visibility::HistoryVisibility, + join_rules::JoinRule, tombstone::TombstoneEventContent, }, tag::Tags, @@ -130,6 +133,14 @@ impl Room { self.inner.read().unwrap().room_type } + /// Whether this room's [`RoomType`](CreateRoomType) is `m.space`. + pub fn is_space(&self) -> bool { + match self.inner.read().unwrap().base_info.create.as_ref() { + Some(create) => create.room_type == Some(CreateRoomType::Space), + None => false, + } + } + /// Get the unread notification counts. pub fn unread_notification_counts(&self) -> UnreadNotificationsCount { self.inner.read().unwrap().notification_counts