Skip to content

Commit b115585

Browse files
authored
Merge pull request #69 from element-hq/langleyd/people-and-rooms-filters
Add people and rooms filters
2 parents e0944c0 + c44396c commit b115585

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

src/Filter.ts

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
import {
22
RoomListEntriesDynamicFilterKind,
33
RoomListEntriesDynamicFilterKind_Tags,
4+
RoomListFilterCategory,
45
} from "./generated/matrix_sdk_ffi";
56

7+
// Special keys for People and Rooms filters since they use Category tag
8+
export const PEOPLE_FILTER_KEY = "Category_People" as const;
9+
export const ROOMS_FILTER_KEY = "Category_Rooms" as const;
10+
611
type FiltersToBePicked = typeof RoomListEntriesDynamicFilterKind_Tags;
712

8-
export type SupportedFilters = keyof Pick<
9-
FiltersToBePicked,
10-
"NonLeft" | "Unread" | "Favourite" | "Invite"
11-
>;
13+
export type SupportedFilters =
14+
| keyof Pick<
15+
FiltersToBePicked,
16+
"NonLeft" | "Unread" | "Favourite" | "Invite"
17+
>
18+
| typeof PEOPLE_FILTER_KEY
19+
| typeof ROOMS_FILTER_KEY;
1220

1321
export const FILTERS = {
1422
[RoomListEntriesDynamicFilterKind_Tags.NonLeft]: {
@@ -29,6 +37,30 @@ export const FILTERS = {
2937
],
3038
}),
3139
},
40+
[PEOPLE_FILTER_KEY]: {
41+
name: "People",
42+
method: new RoomListEntriesDynamicFilterKind.All({
43+
filters: [
44+
new RoomListEntriesDynamicFilterKind.Category({
45+
expect: RoomListFilterCategory.People,
46+
}),
47+
new RoomListEntriesDynamicFilterKind.Joined(),
48+
new RoomListEntriesDynamicFilterKind.DeduplicateVersions(),
49+
],
50+
}),
51+
},
52+
[ROOMS_FILTER_KEY]: {
53+
name: "Rooms",
54+
method: new RoomListEntriesDynamicFilterKind.All({
55+
filters: [
56+
new RoomListEntriesDynamicFilterKind.Category({
57+
expect: RoomListFilterCategory.Group,
58+
}),
59+
new RoomListEntriesDynamicFilterKind.Joined(),
60+
new RoomListEntriesDynamicFilterKind.DeduplicateVersions(),
61+
],
62+
}),
63+
},
3264
[RoomListEntriesDynamicFilterKind_Tags.Favourite]: {
3365
name: "Favourites",
3466
method: new RoomListEntriesDynamicFilterKind.All({

0 commit comments

Comments
 (0)