-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filtering channels does not work #2594
Comments
Hello @AGSTRANGER , it is hard to read your snippets due to the poor formatting. These are the things that come to my mind:
const filters: ChannelFilters = {
members: { $in: [userId] },
member_count: 2,
type: 'messaging',
};
|
Hello again @MartinCupela , I will try to reexplain my problem. Since I already have this filter:
The problem is with Channels search bar: I should not be able to do this. The only was to start a new channel is with the send new message button as this allow any user to create a new channel with any user in the app but with the create new message I only allow users to create conversations with users they're already connected with which works fine:
When I search a channel, I tried to filter the channels to show only the channels the user is a member in by using additionalChannelSearchProps:
But this doesn't work as I can use the search bar to start new channels with other users. |
@MartinCupela I see that you guys shipped a fix for this. I assume the search bar for channels will only search the channels the user is a part of from now on? When will this fix be available on the latest version of the module? |
Describe the bug
Filtering channels does not work. The user is able to send a message to all users by typing their names in the channels filter.
To Reproduce
<ChannelList filters={{ type: "messaging", members: { $in: [connectedUserData._id] }, }} showChannelSearch options={{ state: true, presence: true, limit: 8 }} sort={{ last_message_at: -1 }} additionalChannelSearchProps={{ searchForChannels: true, searchQueryParams: { channelFilters: { filters: { members: { $in: [connectedUserData._id] } }, }, }, }} Preview={ChannelPreviewCustom} />
Steps to reproduce the behavior:
Expected behavior
Only see channels the user is already a part of. In other words, only existing conversations that the user have.
Screenshots
I don't have a conversation with Ali. I shouldn't be able to see him when I type his name in the channels filter.
Additional context
In my app, a user has connections. So when he tries to send a message, he can only send a message to his connection. I have implemented this successfully like this:
`
useEffect(() => {
const fetchUsers = async () => {
if (!connectedUserData) {
setFetchError("Connected user data is not available");
return;
}
}, [searchInputDebounced, connectedUserData, client]);
`
I tried the same thing with filtering channels but it didn't work.
<ChannelList filters={{ type: "messaging", members:{ $and: [ { members: { $in: connectedUserData.connections.map(user => user)} }, // Existing condition:
connectedUserData._idis in
members{ id: { $ne: connectedUserData._id } }, // New condition:
idis not equal to
connectedUserData._id], }, }} showChannelSearch options={{ state: true, presence: true, limit: 8 }} sort={{ last_message_at: -1 }} additionalChannelSearchProps={{ searchForChannels: true, searchQueryParams: { channelFilters: { filters: { $and: [ { members: { $in: connectedUserData.connections.map(user => user)} }, // Existing condition:
connectedUserData._idis in
members{ id: { $ne: connectedUserData._id } }, // New condition:
idis not equal to
connectedUserData._id], }, }, }, }} Preview={ChannelPreviewCustom} />
So I also I tried a simpler filter like the initial example I provided where I only filter by the connected user id but it did not work.
(While writing this, I realized it's redudant to filter channels by both connected user id and his connection requests. Since the user channels can be filtered by either of them. So one is enough.)
Package version
The text was updated successfully, but these errors were encountered: