add type safe filters in queryUsers and queryMembers
Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
@@ -1089,7 +1089,7 @@ class Channel {
|
||||
|
||||
/// Query channel members
|
||||
Future<QueryMembersResponse> queryMembers({
|
||||
Map<String, dynamic>? filter,
|
||||
Filter? filter,
|
||||
List<SortOption>? sort,
|
||||
PaginationParams? pagination,
|
||||
}) async {
|
||||
|
||||
@@ -1020,7 +1020,7 @@ class StreamChatClient {
|
||||
|
||||
/// Requests users with a given query.
|
||||
Future<QueryUsersResponse> queryUsers({
|
||||
Map<String, dynamic>? filter,
|
||||
Filter? filter,
|
||||
List<SortOption>? sort,
|
||||
Map<String, dynamic>? options,
|
||||
PaginationParams? pagination,
|
||||
@@ -1030,7 +1030,7 @@ class StreamChatClient {
|
||||
};
|
||||
|
||||
final payload = <String, dynamic>{
|
||||
'filter_conditions': filter ?? {},
|
||||
'filter_conditions': filter,
|
||||
'sort': sort,
|
||||
}..addAll(defaultOptions);
|
||||
|
||||
|
||||
@@ -363,7 +363,7 @@ void main() {
|
||||
final client = StreamChatClient('api-key', httpClient: mockDio);
|
||||
final queryParams = {
|
||||
'payload': json.encode({
|
||||
'filter_conditions': {},
|
||||
'filter_conditions': null,
|
||||
'sort': null,
|
||||
'presence': false,
|
||||
}),
|
||||
@@ -396,11 +396,7 @@ void main() {
|
||||
when(() => mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = StreamChatClient('api-key', httpClient: mockDio);
|
||||
final queryFilter = <String, dynamic>{
|
||||
'id': {
|
||||
'\$in': ['test'],
|
||||
},
|
||||
};
|
||||
final queryFilter = Filter.in_('id', const ['test']);
|
||||
const sortOptions = <SortOption>[];
|
||||
final options = {'presence': true};
|
||||
final queryParams = <String, dynamic>{
|
||||
|
||||
@@ -1243,11 +1243,10 @@ class MessageInputState extends State<MessageInput> {
|
||||
Future<List<Member>> queryMembers;
|
||||
|
||||
if (query.isNotEmpty) {
|
||||
queryMembers = StreamChannel.of(context).channel.queryMembers(filter: {
|
||||
'name': {
|
||||
'\$autocomplete': query,
|
||||
},
|
||||
}).then((res) => res.members);
|
||||
queryMembers = StreamChannel.of(context)
|
||||
.channel
|
||||
.queryMembers(filter: Filter.autoComplete('name', query))
|
||||
.then((res) => res.members);
|
||||
}
|
||||
|
||||
final members = StreamChannel.of(context).channel.state.members?.where((m) {
|
||||
|
||||
@@ -72,7 +72,7 @@ class UserListView extends StatefulWidget {
|
||||
/// The query filters to use.
|
||||
/// You can query on any of the custom fields you've defined on the [Channel].
|
||||
/// You can also filter other built-in channel fields.
|
||||
final Map<String, dynamic> filter;
|
||||
final Filter filter;
|
||||
|
||||
/// Query channels options.
|
||||
///
|
||||
|
||||
@@ -90,7 +90,7 @@ class UserListCore extends StatefulWidget {
|
||||
/// The query filters to use.
|
||||
/// You can query on any of the custom fields you've defined on the [Channel].
|
||||
/// You can also filter other built-in channel fields.
|
||||
final Map<String, dynamic>? filter;
|
||||
final Filter? filter;
|
||||
|
||||
/// Query channels options.
|
||||
///
|
||||
|
||||
@@ -58,7 +58,7 @@ class UsersBlocState extends State<UsersBloc>
|
||||
/// online/offline.
|
||||
/// [API Reference](https://getstream.io/chat/docs/flutter-dart/query_users/?language=dart)
|
||||
Future<void> queryUsers({
|
||||
Map<String, dynamic>? filter,
|
||||
Filter? filter,
|
||||
List<SortOption>? sort,
|
||||
Map<String, dynamic>? options,
|
||||
PaginationParams? pagination,
|
||||
|
||||
Reference in New Issue
Block a user