cargo fmt/clippy
parent
a29ae2a62e
commit
82f8af4c08
|
@ -14,7 +14,6 @@
|
|||
// limitations under the License.
|
||||
|
||||
use futures::future::{BoxFuture, Future, FutureExt};
|
||||
use std::collections::HashMap;
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
use std::sync::{Arc, Mutex, RwLock as SyncLock};
|
||||
|
|
|
@ -21,7 +21,7 @@ use crate::events::room::{
|
|||
aliases::AliasesEvent,
|
||||
canonical_alias::CanonicalAliasEvent,
|
||||
member::{MemberEvent, MembershipState},
|
||||
name::{NameEvent},
|
||||
name::NameEvent,
|
||||
};
|
||||
use crate::events::EventResult;
|
||||
use crate::identifiers::RoomAliasId;
|
||||
|
@ -110,7 +110,11 @@ impl RoomName {
|
|||
self.aliases[0].alias().to_string()
|
||||
} else {
|
||||
// TODO
|
||||
let mut names = members.values().flat_map(|m| m.display_name.clone()).take(3).collect::<Vec<_>>();
|
||||
let mut names = members
|
||||
.values()
|
||||
.flat_map(|m| m.display_name.clone())
|
||||
.take(3)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if names.is_empty() {
|
||||
// TODO implement the rest of matrix-js-sdk handling of room names
|
||||
|
@ -118,7 +122,7 @@ impl RoomName {
|
|||
} else {
|
||||
// stabilize order
|
||||
names.sort();
|
||||
names.join(", ").to_string()
|
||||
names.join(", ")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -353,13 +357,21 @@ impl Client {
|
|||
}
|
||||
|
||||
pub(crate) fn calculate_room_name(&self, room_id: &str) -> Option<String> {
|
||||
self.joined_rooms.get(room_id)
|
||||
.and_then(|r| r.read().map(|r| r.room_name.calculate_name(room_id, &r.members)).ok())
|
||||
self.joined_rooms.get(room_id).and_then(|r| {
|
||||
r.read()
|
||||
.map(|r| r.room_name.calculate_name(room_id, &r.members))
|
||||
.ok()
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn calculate_room_names(&self) -> Vec<String> {
|
||||
self.joined_rooms.iter()
|
||||
.flat_map(|(id, room)| room.read().map(|r| r.room_name.calculate_name(id, &r.members)).ok())
|
||||
self.joined_rooms
|
||||
.iter()
|
||||
.flat_map(|(id, room)| {
|
||||
room.read()
|
||||
.map(|r| r.room_name.calculate_name(id, &r.members))
|
||||
.ok()
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,6 @@ fn sync() {
|
|||
assert!(rt.block_on(client.sync_token()).is_some());
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn timeline() {
|
||||
let mut rt = Runtime::new().unwrap();
|
||||
|
@ -87,7 +86,10 @@ fn timeline() {
|
|||
let _response = rt.block_on(client.sync(sync_settings)).unwrap();
|
||||
|
||||
assert_eq!(vec!["tutorial"], rt.block_on(client.get_room_names()));
|
||||
assert_eq!(Some("tutorial".into()), rt.block_on(client.get_room_name("!SVkFJHzfwvuaIEawgC:localhost")));
|
||||
assert_eq!(
|
||||
Some("tutorial".into()),
|
||||
rt.block_on(client.get_room_name("!SVkFJHzfwvuaIEawgC:localhost"))
|
||||
);
|
||||
|
||||
// rt.block_on(async { println!("{:#?}", &client.base_client().await.joined_rooms ) });
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue