added a few todos, cargo fmt/clippy

This commit is contained in:
Devin R 2020-03-30 07:14:33 -04:00
parent 14a8d04a03
commit 705464fb51
5 changed files with 24 additions and 21 deletions

View file

@ -533,6 +533,7 @@ impl AsyncClient {
}
// look at AccountData to further cut down users by collecting ignored users
// TODO actually use the ignored users
for account_data in &room.account_data.events {
let mut client = self.base_client.write().await;
if let EventResult::Ok(e) = account_data {

View file

@ -26,7 +26,7 @@ use crate::events::presence::PresenceEvent;
// `NonRoomEvent` is what it is aliased as
use crate::events::collections::only::Event as NonRoomEvent;
use crate::events::ignored_user_list::IgnoredUserListEvent;
use crate::events::push_rules::{ Ruleset, PushRulesEvent};
use crate::events::push_rules::{PushRulesEvent, Ruleset};
use crate::events::room::{
aliases::AliasesEvent,
canonical_alias::CanonicalAliasEvent,
@ -81,7 +81,8 @@ impl CurrentRoom {
pub(crate) fn update(&mut self, room_id: &str, event: &PresenceEvent) {
self.last_active = event.content.last_active_ago;
self.current_room_id = Some(RoomId::try_from(room_id).expect("room id failed CurrentRoom::update"));
self.current_room_id =
Some(RoomId::try_from(room_id).expect("room id failed CurrentRoom::update"));
}
}
@ -209,10 +210,22 @@ impl Client {
/// Returns true if the room name changed, false otherwise.
pub(crate) fn handle_ignored_users(&mut self, event: &IgnoredUserListEvent) -> bool {
// TODO use actual UserId instead of string?
if self.ignored_users == event.content.ignored_users.iter().map(|u| u.to_string()).collect::<Vec<String>>() {
if self.ignored_users
== event
.content
.ignored_users
.iter()
.map(|u| u.to_string())
.collect::<Vec<String>>()
{
false
} else {
self.ignored_users = event.content.ignored_users.iter().map(|u| u.to_string()).collect();
self.ignored_users = event
.content
.ignored_users
.iter()
.map(|u| u.to_string())
.collect();
true
}
}
@ -304,7 +317,11 @@ impl Client {
///
/// * `event` - The event that should be handled by the client.
pub fn receive_presence_event(&mut self, room_id: &str, event: &PresenceEvent) -> bool {
let user_id = &self.session.as_ref().expect("to receive events you must be logged in").user_id;
let user_id = &self
.session
.as_ref()
.expect("to receive events you must be logged in")
.user_id;
if self.current_room_id.comes_after(user_id, event) {
self.current_room_id.update(room_id, event);
}

View file

@ -1,6 +1,5 @@
mod room;
mod room_member;
mod room_state;
mod user;
pub use room::{Room, RoomName};

View file

@ -1,14 +0,0 @@
// Copyright 2020 Damir Jelić
// Copyright 2020 The Matrix.org Foundation C.I.C.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

View file

@ -128,7 +128,7 @@ impl User {
*self = User {
display_name: displayname.clone(),
avatar_url: avatar_url.clone(),
presence: Some(presence.clone()),
presence: Some(*presence),
status_msg: status_msg.clone(),
last_active_ago: *last_active_ago,
currently_active: *currently_active,