From bb234ca0020f874da07ffcb62ca96066d85836ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20K=C3=B6sters?= Date: Thu, 22 Apr 2021 11:27:01 +0200 Subject: [PATCH] fix: only show one typing event per user --- src/database/rooms/edus.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/database/rooms/edus.rs b/src/database/rooms/edus.rs index c48f4c23..f69e897c 100644 --- a/src/database/rooms/edus.rs +++ b/src/database/rooms/edus.rs @@ -9,7 +9,7 @@ use ruma::{ RoomId, UInt, UserId, }; use std::{ - collections::HashMap, + collections::{HashMap, HashSet}, convert::{TryFrom, TryInto}, mem, }; @@ -280,7 +280,7 @@ impl RoomEdus { let mut prefix = room_id.as_bytes().to_vec(); prefix.push(0xff); - let mut user_ids = Vec::new(); + let mut user_ids = HashSet::new(); for user_id in self .typingid_userid @@ -295,11 +295,13 @@ impl RoomEdus { ) }) { - user_ids.push(user_id?); + user_ids.insert(user_id?); } Ok(SyncEphemeralRoomEvent { - content: ruma::events::typing::TypingEventContent { user_ids }, + content: ruma::events::typing::TypingEventContent { + user_ids: user_ids.into_iter().collect(), + }, }) }