style(presence): use flat_map instead of matching Results in filter
This commit is contained in:
@@ -29,5 +29,5 @@ pub trait Data: Send + Sync {
|
||||
&'a self,
|
||||
room_id: &RoomId,
|
||||
since: u64,
|
||||
) -> Box<dyn Iterator<Item = Result<(OwnedUserId, u64, PresenceEvent)>> + 'a>;
|
||||
) -> Box<dyn Iterator<Item = (OwnedUserId, u64, PresenceEvent)> + 'a>;
|
||||
}
|
||||
|
||||
@@ -122,11 +122,11 @@ impl Service {
|
||||
}
|
||||
|
||||
/// Returns the most recent presence updates that happened after the event with id `since`.
|
||||
pub fn presence_since<'a>(
|
||||
&'a self,
|
||||
pub fn presence_since(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
since: u64,
|
||||
) -> Box<dyn Iterator<Item = Result<(OwnedUserId, u64, PresenceEvent)>> + 'a> {
|
||||
) -> Box<dyn Iterator<Item = (OwnedUserId, u64, PresenceEvent)>> {
|
||||
self.db.presence_since(room_id, since)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,14 +290,12 @@ impl Service {
|
||||
// Look for presence updates in this room
|
||||
let mut presence_updates = Vec::new();
|
||||
|
||||
for presence_data in services()
|
||||
for (user_id, count, presence_event) in services()
|
||||
.rooms
|
||||
.edus
|
||||
.presence
|
||||
.presence_since(&room_id, since)
|
||||
{
|
||||
let (user_id, count, presence_event) = presence_data?;
|
||||
|
||||
if count > max_edu_count {
|
||||
max_edu_count = count;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user