🎨 Factorize Room creation from MatrixRoom instances
This commit is contained in:
13
src/base.rs
13
src/base.rs
@@ -7,9 +7,8 @@ use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
use dioxus::prelude::*;
|
||||
use fermi::*;
|
||||
use matrix_sdk::room::Room as MatrixRoom;
|
||||
use matrix_sdk::{
|
||||
room::RoomMember,
|
||||
room::{Room as MatrixRoom, RoomMember},
|
||||
ruma::{OwnedRoomId, OwnedUserId},
|
||||
};
|
||||
use tokio::select;
|
||||
@@ -63,6 +62,16 @@ impl Room {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn from_matrix_room(matrix_room: &MatrixRoom) -> Self {
|
||||
let room_topic = matrix_room.topic().map(RefCell::new);
|
||||
|
||||
Self::new(
|
||||
Arc::new(matrix_room.to_owned()),
|
||||
room_topic,
|
||||
matrix_room.is_direct().await.ok(),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn name(&self) -> Option<String> {
|
||||
self.matrix_room.name()
|
||||
}
|
||||
|
Reference in New Issue
Block a user