From b063b25e8c6272952ef1adbaf1d3f810657ee169 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 16 Dec 2022 20:39:44 +0100 Subject: [PATCH] Ignore typing notification for ignored users (part of #2965) --- .../session/sync/handler/room/RoomTypingUsersHandler.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/room/RoomTypingUsersHandler.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/room/RoomTypingUsersHandler.kt index 54bb63753c..7735023cc8 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/room/RoomTypingUsersHandler.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/room/RoomTypingUsersHandler.kt @@ -18,6 +18,7 @@ package org.matrix.android.sdk.internal.session.sync.handler.room import io.realm.Realm import org.matrix.android.sdk.api.session.room.sender.SenderInfo +import org.matrix.android.sdk.internal.database.model.IgnoredUserEntity import org.matrix.android.sdk.internal.di.UserId import org.matrix.android.sdk.internal.session.room.membership.RoomMemberHelper import org.matrix.android.sdk.internal.session.typing.DefaultTypingUsersTracker @@ -30,8 +31,10 @@ internal class RoomTypingUsersHandler @Inject constructor( // TODO This could be handled outside of the Realm transaction. Use the new aggregator? fun handle(realm: Realm, roomId: String, ephemeralResult: RoomSyncHandler.EphemeralResult?) { + // Filter ignored users and current user + val filteredUserIds = realm.where(IgnoredUserEntity::class.java).findAll().map { it.userId } + userId val roomMemberHelper = RoomMemberHelper(realm, roomId) - val typingIds = ephemeralResult?.typingUserIds?.filter { it != userId }.orEmpty() + val typingIds = ephemeralResult?.typingUserIds?.filter { it !in filteredUserIds }.orEmpty() val senderInfo = typingIds.map { userId -> val roomMemberSummaryEntity = roomMemberHelper.getLastRoomMember(userId) SenderInfo(