fix slice match room_aliases

master
Devin R 2020-03-27 20:17:06 -04:00
parent 3df15b72eb
commit c2022180ad
3 changed files with 9 additions and 4 deletions

View File

@ -263,8 +263,8 @@ impl AsyncClient {
#[doc(hidden)] #[doc(hidden)]
/// Access to the underlying `BaseClient`. Used for testing and debugging so far. /// Access to the underlying `BaseClient`. Used for testing and debugging so far.
pub async fn base_client(&self) -> RwLockReadGuard<'_, BaseClient> { pub fn base_client(&self) -> Arc<RwLock<BaseClient>> {
self.base_client.read().await Arc::clone(&self.base_client)
} }
/// Calculate the room name from a `RoomId`, returning a string. /// Calculate the room name from a `RoomId`, returning a string.

View File

@ -199,6 +199,7 @@ impl Room {
} }
/// Handle a room.member updating the room state if necessary. /// Handle a room.member updating the room state if necessary.
///
/// Returns true if the joined member list changed, false otherwise. /// Returns true if the joined member list changed, false otherwise.
pub fn handle_membership(&mut self, event: &MemberEvent) -> bool { pub fn handle_membership(&mut self, event: &MemberEvent) -> bool {
match event.content.membership { match event.content.membership {
@ -229,15 +230,18 @@ impl Room {
} }
/// Handle a room.aliases event, updating the room state if necessary. /// Handle a room.aliases event, updating the room state if necessary.
///
/// Returns true if the room name changed, false otherwise. /// Returns true if the room name changed, false otherwise.
pub fn handle_room_aliases(&mut self, event: &AliasesEvent) -> bool { pub fn handle_room_aliases(&mut self, event: &AliasesEvent) -> bool {
match event.content.aliases.as_slice() { match event.content.aliases.as_slice() {
[alias] => self.room_aliases(alias), [alias] => self.room_aliases(alias),
[alias, ..] => self.room_aliases(alias),
_ => false, _ => false,
} }
} }
/// Handle a room.canonical_alias event, updating the room state if necessary. /// Handle a room.canonical_alias event, updating the room state if necessary.
///
/// Returns true if the room name changed, false otherwise. /// Returns true if the room name changed, false otherwise.
pub fn handle_canonical(&mut self, event: &CanonicalAliasEvent) -> bool { pub fn handle_canonical(&mut self, event: &CanonicalAliasEvent) -> bool {
match &event.content.alias { match &event.content.alias {
@ -247,6 +251,7 @@ impl Room {
} }
/// Handle a room.name event, updating the room state if necessary. /// Handle a room.name event, updating the room state if necessary.
///
/// Returns true if the room name changed, false otherwise. /// Returns true if the room name changed, false otherwise.
pub fn handle_room_name(&mut self, event: &NameEvent) -> bool { pub fn handle_room_name(&mut self, event: &NameEvent) -> bool {
match event.content.name() { match event.content.name() {

View File

@ -91,5 +91,5 @@ fn timeline() {
rt.block_on(client.get_room_name("!SVkFJHzfwvuaIEawgC:localhost")) 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 ) });
} }