mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-15 03:25:46 -04:00
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:
@@ -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 })
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user