Open guplem opened 2 weeks ago
Hey @guplem 👋
Just confirming something - your second filter seems wrong but that could just be a typo. Can you confirm this filter does not work for you:
StreamChannelListController(
client: ChatV3Service().client,
filter: Filter.and([
Filter.in_('members', [AuthServiceV2().userId!]),
Filter.equal('type', type.value),
Filter.in_('accepted', ["f2e808cf-c8fd-413b-8ceb-4d405cfc5cc3"]),
]),
channelStateSort: const [SortOption('last_message_at')],
)
Difference being the list in the last filter.
@deven98 sadly, it's just a typo...
If I do filter the chats like this, no chats are returned:
StreamChannelListController(
client: await clientInitialized,
filter: Filter.and([
Filter.in_('members', [AuthServiceV2().userId!]),
Filter.equal('type', type.value),
Filter.in_('accepted', [AuthServiceV2().userId!]),
]),
channelStateSort: const [SortOption('last_message_at')],
)
Where AuthServiceV2().userId!
is equivalent to "f2e808cf-c8fd-413b-8ceb-4d405cfc5cc3"
.
And, as you can see highlighted, the user with that ID is in the members and accepted
array:
The cid of that chat is
dm:!members--XJeuxomoxXJoCuNajOsgbF_ZvIYnWN28hecgVZdXBo
Which packages are you using?
stream_chat_flutter
On what platforms did you experience the issue?
Android
What version are you using?
^7.2.1
What happened?
I am trying to filter chats using a custom field with no success.
This is the code snippet we're using:
However, this filter does not work as expected. No channels are returned when we include the
Filter.contains('accepted', [AuthServiceV2().userId!])
. If we remove this filter, we do get channels, including those with the "accepted" field containing the intended ID.Detailed Explanation:
AuthServiceV2().userId!
equivalent tof2e808cf-c8fd-413b-8ceb-4d405cfc5cc3
.accepted
is an array of strings (custom, added from the backed upon "channel creation" and returned as "extraData" in the channel object in flutter).accepted
contains the user ID.Another example of a non-working filter:
Sorting by a custom field example:
Additional Information:
Expected Behavior:
Channels should be filtered correctly where the
accepted
field contains the specified user ID.Observed Behavior:
No channels are returned when applying the "contains" nor the "_in" filter.
Request:
Could you please test and verify this using Flutter and provide guidance or fixes for:
contains
.Thank you, Guillem Poy
Steps to reproduce
Supporting info to reproduce
No response
Relevant log output
No response
Flutter analyze output
Flutter doctor output
Code of Conduct