From 0cd0ade2bcc8ba4b7018c70aa86517db37a85c36 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Thu, 29 Jun 2023 14:48:37 +0200 Subject: [PATCH] feat(ffi): Add methods on `RoomListItem` so that `full_room` isn't necessary. Calling `RoomListItem::full_room` creates its associated `Timeline`. ElementX calls `full_room` to get the `is_direct`, `avatar_url` and `canonical_alias` values for _all_ rooms in the room list. Instead of doing so, let's add those methods directly in `RoomListItem` so that the `Timeline` isn't created for _all_ rooms. --- bindings/matrix-sdk-ffi/src/room_list.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bindings/matrix-sdk-ffi/src/room_list.rs b/bindings/matrix-sdk-ffi/src/room_list.rs index 2b3ac5f91..a047bfb1e 100644 --- a/bindings/matrix-sdk-ffi/src/room_list.rs +++ b/bindings/matrix-sdk-ffi/src/room_list.rs @@ -339,6 +339,18 @@ impl RoomListItem { RUNTIME.block_on(async { self.inner.name().await }) } + pub fn is_direct(&self) -> Option { + RUNTIME.block_on(async { self.inner.inner_room().is_direct().await.ok() }) + } + + pub fn avatar_url(&self) -> Option { + self.inner.inner_room().avatar_url().map(|uri| uri.to_string()) + } + + pub fn canonical_alias(&self) -> Option { + self.inner.inner_room().canonical_alias().map(|alias| alias.to_string()) + } + fn full_room(&self) -> Arc { Arc::new(Room::with_timeline( self.inner.inner_room().clone(),