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