Actually set room when running SetRoomCommand #79

Merged
projectmoon merged 3 commits from set-room-command-actually-set-room into master 2021-05-29 20:26:23 +00:00
1 changed files with 7 additions and 1 deletions
Showing only changes of commit 4fb83a0fef - Show all commits

View File

@ -64,7 +64,7 @@ async fn get_rooms_for_user(
) -> Result<Vec<RoomNameAndId>, BotError> {
let user_id = UserId::try_from(user_id)?;
let rooms_for_user = matrix::get_rooms_for_user(client, &user_id).await?;
let rooms_for_user: Vec<RoomNameAndId> = stream::iter(rooms_for_user)
let mut rooms_for_user: Vec<RoomNameAndId> = stream::iter(rooms_for_user)
.filter_map(|room| async move {
Some(room.display_name().await.map(|room_name| RoomNameAndId {
id: room.room_id().to_string(),
@ -74,6 +74,12 @@ async fn get_rooms_for_user(
.try_collect()
.await?;
//Alphabetically descending, symbols first, ignore case.
let sort = |r1: &RoomNameAndId, r2: &RoomNameAndId| {
r1.name.to_lowercase().cmp(&r2.name.to_lowercase())
};
rooms_for_user.sort_by(sort);
Ok(rooms_for_user)
}