mirror of
https://github.com/vector-im/element-web.git
synced 2025-11-09 20:51:41 +01:00
Don't clear filters on space change (#30903)
This commit is contained in:
parent
a9f4ccaa02
commit
7e48f2b6b6
@ -15,8 +15,6 @@ import RoomListStoreV3, {
|
|||||||
type RoomsResult,
|
type RoomsResult,
|
||||||
} from "../../../stores/room-list-v3/RoomListStoreV3";
|
} from "../../../stores/room-list-v3/RoomListStoreV3";
|
||||||
import { useEventEmitter } from "../../../hooks/useEventEmitter";
|
import { useEventEmitter } from "../../../hooks/useEventEmitter";
|
||||||
import SpaceStore from "../../../stores/spaces/SpaceStore";
|
|
||||||
import { UPDATE_SELECTED_SPACE } from "../../../stores/spaces";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides information about a primary filter.
|
* Provides information about a primary filter.
|
||||||
@ -74,9 +72,6 @@ export function useFilteredRooms(): FilteredRooms {
|
|||||||
setRoomsResult(newRooms);
|
setRoomsResult(newRooms);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Reset filters when active space changes
|
|
||||||
useEventEmitter(SpaceStore.instance, UPDATE_SELECTED_SPACE, () => setPrimaryFilter(undefined));
|
|
||||||
|
|
||||||
const filterUndefined = (array: (FilterKey | undefined)[]): FilterKey[] =>
|
const filterUndefined = (array: (FilterKey | undefined)[]): FilterKey[] =>
|
||||||
array.filter((f) => f !== undefined) as FilterKey[];
|
array.filter((f) => f !== undefined) as FilterKey[];
|
||||||
|
|
||||||
|
|||||||
@ -127,7 +127,7 @@ describe("RoomListViewModel", () => {
|
|||||||
expect(vm.current.activePrimaryFilter).toEqual(vm.current.primaryFilters[i]);
|
expect(vm.current.activePrimaryFilter).toEqual(vm.current.primaryFilters[i]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should remove all filters when active space is changed", async () => {
|
it("should not remove all filters when active space is changed", async () => {
|
||||||
mockAndCreateRooms();
|
mockAndCreateRooms();
|
||||||
const { result: vm } = renderHook(() => useRoomListViewModel());
|
const { result: vm } = renderHook(() => useRoomListViewModel());
|
||||||
|
|
||||||
@ -141,8 +141,8 @@ describe("RoomListViewModel", () => {
|
|||||||
// Simulate a space change
|
// Simulate a space change
|
||||||
await act(() => SpaceStore.instance.emit(UPDATE_SELECTED_SPACE));
|
await act(() => SpaceStore.instance.emit(UPDATE_SELECTED_SPACE));
|
||||||
|
|
||||||
// Primary filer should have been unapplied
|
// Primary filter should remain unchanged
|
||||||
expect(vm.current.activePrimaryFilter).toEqual(undefined);
|
expect(vm.current.activePrimaryFilter?.name).toEqual("People");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user