matrix-org / matrix-org/matrix-rust-sdk
Add "Not" or "Exclude" Filter to RoomListEntriesDynamicFilterKind
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 2.3k
- Forks
- 500
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 106
Description
Hello, I'm writing on behalf of the Citadel product developed by ERCOM.
### Add capability to exclude specific filters (like Favorites) within RoomListEntriesDynamicFilterKind
## Description
Currently, when setting up room list subscriptions, we can combine filters using `.All()` (AND logic) or `.Any()` (OR logic). However, there is no mechanism to *exclude* or *negate* a filter.
We are implementing a standard 3-section room list:
1. **Favorites**: `All(Favourite, Joined)`
2. **Direct Messages**: `All(Category.People, Joined)`
3. **Regular Rooms**: `All(Category.Group, Joined)`
**The Problem:**
A room that is both a "Direct Message" AND a "Favorite" appears in *both* the Favorites section and the Direct Messages section.
To prevent duplicates in the UI, we currently have to:
1. Fetch the room in the Direct Messages subscription.
2. Fetch its metadata.
3. Check `isFavourite`.
4. Manually filter it out on the client side.
This is inefficient because:
- We receive updates for rooms we don't intend to show in that section.
- We have to maintain complex client-side filtering logic.
- It complicates index-based updates (Insert/Remove) because the SDK's index includes the hidden rooms.
## Suggested Solution
Please add a `Not` filter kind or an `exclude` property to the existing filter system.
### `Not` Filter Wrapper
Allow wrapping a filter in a negation:
```javascript
new RoomListEntriesDynamicFilterKind.All({
filters: [
new RoomListEntriesDynamicFilterKind.Category({ expect: RoomListFilterCategory.People }),
new RoomListEntriesDynamicFilterKind.Joined(),
// NEW: Exclude favorites
new RoomListEntriesDynamicFilterKind.Not({
filter: new RoomListEntriesDynamicFilterKind.Favourite()
})
]
})
```
## Impact
- Reduces client-side memory usage (no duplicate storage).
- Reduces network traffic (no updates for hidden rooms).
- Simplifies client-side state management (removes risk of index corruption during manual filtering).
## Acceptance Criteria
1. SDK accepts a filter configuration that excludes Favorite rooms.
2. The `RoomListEntriesListener` does *not* receive `Append`, `Insert`, or `Push` events for rooms that match the excluded criteria.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating RoomListEntriesDynamicFilterKind and the RoomListEntriesListener implementation, then trace how All and Any filters are evaluated and how Append, Insert, and Push events are selected. Define the scope of a negated filter from the existing filter model, and verify that excluded Favorite rooms produce none of the specified listener events.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100