From 8c2dbc342b9cd54f346ec0fdbda6dddd04be913a Mon Sep 17 00:00:00 2001
From: SpiritCroc <dev@spiritcroc.de>
Date: Sat, 26 Dec 2020 14:28:42 +0100
Subject: [PATCH] Fix member state setting filter

What we want with that setting:
- When enabled, include all member state events
- When disable, exclude all member state events

What it did:
- When enabled, exclude all member state events except from the
  logged-in user
- When disabled, include all member state events

Change-Id: I86eec2188163dc3265444e121d230ce0cb9c7f7a
---
 .../detail/timeline/helper/TimelineSettingsFactory.kt     | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/TimelineSettingsFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/TimelineSettingsFactory.kt
index 1983b05ed3..e3ef432a62 100644
--- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/TimelineSettingsFactory.kt
+++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/TimelineSettingsFactory.kt
@@ -54,11 +54,15 @@ class TimelineSettingsFactory @Inject constructor(
     }
 
     private fun List<String>.createAllowedEventTypeFilters(): List<EventTypeFilter> {
-        return map {
+        var result = map {
             EventTypeFilter(
                     eventType = it,
-                    stateKey = if (it == EventType.STATE_ROOM_MEMBER && userPreferencesProvider.shouldShowRoomMemberStateEvents()) session.myUserId else null
+                    stateKey = null
             )
         }
+        if (!userPreferencesProvider.shouldShowRoomMemberStateEvents()) {
+            result = result.filter { it.eventType != EventType.STATE_ROOM_MEMBER }
+        }
+        return result
     }
 }