fix slice match room_aliases
This commit is contained in:
parent
6b5a357e33
commit
7062bdb484
3 changed files with 9 additions and 4 deletions
|
@ -262,10 +262,10 @@ impl AsyncClient {
|
|||
|
||||
#[doc(hidden)]
|
||||
/// Access to the underlying `BaseClient`. Used for testing and debugging so far.
|
||||
pub async fn base_client(&self) -> RwLockReadGuard<'_, BaseClient> {
|
||||
self.base_client.read().await
|
||||
pub fn base_client(&self) -> Arc<RwLock<BaseClient>> {
|
||||
Arc::clone(&self.base_client)
|
||||
}
|
||||
|
||||
|
||||
/// Calculate the room name from a `RoomId`, returning a string.
|
||||
pub async fn get_room_name(&self, room_id: &str) -> Option<String> {
|
||||
self.base_client.read().await.calculate_room_name(room_id)
|
||||
|
|
|
@ -203,6 +203,7 @@ impl Room {
|
|||
}
|
||||
|
||||
/// Handle a room.member updating the room state if necessary.
|
||||
///
|
||||
/// Returns true if the joined member list changed, false otherwise.
|
||||
pub fn handle_membership(&mut self, event: &MemberEvent) -> bool {
|
||||
match event.content.membership {
|
||||
|
@ -233,15 +234,18 @@ impl Room {
|
|||
}
|
||||
|
||||
/// Handle a room.aliases event, updating the room state if necessary.
|
||||
///
|
||||
/// Returns true if the room name changed, false otherwise.
|
||||
pub fn handle_room_aliases(&mut self, event: &AliasesEvent) -> bool {
|
||||
match event.content.aliases.as_slice() {
|
||||
[alias] => self.room_aliases(alias),
|
||||
[alias, ..] => self.room_aliases(alias),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Handle a room.canonical_alias event, updating the room state if necessary.
|
||||
///
|
||||
/// Returns true if the room name changed, false otherwise.
|
||||
pub fn handle_canonical(&mut self, event: &CanonicalAliasEvent) -> bool {
|
||||
match &event.content.alias {
|
||||
|
@ -251,6 +255,7 @@ impl Room {
|
|||
}
|
||||
|
||||
/// Handle a room.name event, updating the room state if necessary.
|
||||
///
|
||||
/// Returns true if the room name changed, false otherwise.
|
||||
pub fn handle_room_name(&mut self, event: &NameEvent) -> bool {
|
||||
match event.content.name() {
|
||||
|
|
|
@ -92,5 +92,5 @@ fn timeline() {
|
|||
rt.block_on(client.get_room_name("!SVkFJHzfwvuaIEawgC:localhost"))
|
||||
);
|
||||
|
||||
// rt.block_on(async { println!("{:#?}", &client.base_client().await.joined_rooms ) });
|
||||
// rt.block_on(async { println!("{:#?}", &client.base_client().read().await.joined_rooms ) });
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue