From df6b7d0d2100f0fa32173a806b634ac53554414e Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Wed, 12 Aug 2026 17:19:13 +0300 Subject: [PATCH] Avoid re-applying identical room list filters The home screen's filter observation fires on every view state change, so setFilter was repeatedly pushing the same filter down into the SDK. Cache the last applied filter and skip the SDK call when it hasn't changed. --- .../Services/Room/RoomSummary/RoomSummaryProvider.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ElementX/Sources/Services/Room/RoomSummary/RoomSummaryProvider.swift b/ElementX/Sources/Services/Room/RoomSummary/RoomSummaryProvider.swift index e60eeb20e..7960f7ef5 100644 --- a/ElementX/Sources/Services/Room/RoomSummary/RoomSummaryProvider.swift +++ b/ElementX/Sources/Services/Room/RoomSummary/RoomSummaryProvider.swift @@ -27,6 +27,7 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol { private var cancellables = Set() private var listUpdatesSubscriptionResult: RoomListEntriesWithDynamicAdaptersResult? + private var currentFilter: RoomSummaryProviderFilter? private var stateUpdatesTaskHandle: TaskHandle? private let roomListSubject = CurrentValueSubject<[RoomSummary], Never>([]) @@ -117,6 +118,7 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol { }) // Forces the listener above to be called with the current state + currentFilter = nil setFilter(.all(filters: [])) let stateUpdatesSubscriptionResult = try roomList.loadingState(listener: SDKListener { [loadingStateContinuation] state in @@ -136,6 +138,12 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol { } func setFilter(_ filter: RoomSummaryProviderFilter) { + guard filter != currentFilter else { + return + } + + currentFilter = filter + let baseFilter: [RoomListEntriesDynamicFilterKind] = [.any(filters: [.all(filters: [.nonSpace, .nonLeft]), .all(filters: [.space, .invite])]), .deduplicateVersions]