feat(ui+ffi): Implement Room::id as a shortcut.

It's possible to do `room.inner_room().room_id()` but it's just simpler
to call `room.id()`. This patch adds this shortcut.

It's especially useful for FFI users, where creating a “full
room” (`room_item.full_room().room_id()`) may be expensive.
This commit is contained in:
Ivan Enderlin
2023-06-14 10:59:03 +02:00
parent dba397d470
commit 192b9ce808
2 changed files with 10 additions and 1 deletions

View File

@@ -194,6 +194,10 @@ pub struct RoomListItem {
#[uniffi::export]
impl RoomListItem {
fn id(&self) -> String {
self.inner.id().to_string()
}
fn name(&self) -> Option<String> {
RUNTIME.block_on(async { self.inner.name().await })
}

View File

@@ -4,7 +4,7 @@ use std::sync::Arc;
use async_once_cell::OnceCell as AsyncOnceCell;
use matrix_sdk::{SlidingSync, SlidingSyncRoom};
use ruma::api::client::sync::sync_events::v4::RoomSubscription;
use ruma::{api::client::sync::sync_events::v4::RoomSubscription, RoomId};
use super::Error;
use crate::{timeline::EventTimelineItem, Timeline};
@@ -58,6 +58,11 @@ impl Room {
})
}
/// Get the room ID.
pub fn id(&self) -> &RoomId {
self.inner.room.room_id()
}
/// Get the best possible name for the room.
///
/// If the sliding sync room has received a name from the server, then use