Skip to content

Commit 7e48f2b

Browse files
authored
Don't clear filters on space change (#30903)
1 parent a9f4cca commit 7e48f2b

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

src/components/viewmodels/roomlist/useFilteredRooms.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import RoomListStoreV3, {
1515
type RoomsResult,
1616
} from "../../../stores/room-list-v3/RoomListStoreV3";
1717
import { useEventEmitter } from "../../../hooks/useEventEmitter";
18-
import SpaceStore from "../../../stores/spaces/SpaceStore";
19-
import { UPDATE_SELECTED_SPACE } from "../../../stores/spaces";
2018

2119
/**
2220
* Provides information about a primary filter.
@@ -74,9 +72,6 @@ export function useFilteredRooms(): FilteredRooms {
7472
setRoomsResult(newRooms);
7573
}, []);
7674

77-
// Reset filters when active space changes
78-
useEventEmitter(SpaceStore.instance, UPDATE_SELECTED_SPACE, () => setPrimaryFilter(undefined));
79-
8075
const filterUndefined = (array: (FilterKey | undefined)[]): FilterKey[] =>
8176
array.filter((f) => f !== undefined) as FilterKey[];
8277

test/unit-tests/components/viewmodels/roomlist/RoomListViewModel-test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ describe("RoomListViewModel", () => {
127127
expect(vm.current.activePrimaryFilter).toEqual(vm.current.primaryFilters[i]);
128128
});
129129

130-
it("should remove all filters when active space is changed", async () => {
130+
it("should not remove all filters when active space is changed", async () => {
131131
mockAndCreateRooms();
132132
const { result: vm } = renderHook(() => useRoomListViewModel());
133133

@@ -141,8 +141,8 @@ describe("RoomListViewModel", () => {
141141
// Simulate a space change
142142
await act(() => SpaceStore.instance.emit(UPDATE_SELECTED_SPACE));
143143

144-
// Primary filer should have been unapplied
145-
expect(vm.current.activePrimaryFilter).toEqual(undefined);
144+
// Primary filter should remain unchanged
145+
expect(vm.current.activePrimaryFilter?.name).toEqual("People");
146146
});
147147
});
148148

0 commit comments

Comments
 (0)