1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 12:59:21 +00:00

Fix issue with new API

This commit is contained in:
Pierre HUBERT 2020-04-16 15:14:27 +02:00
parent 0ec0f216e2
commit 90cbd7ab23

View File

@ -1,31 +1,24 @@
import 'package:comunic/helpers/users_helper.dart'; import 'package:comunic/helpers/users_helper.dart';
import 'package:comunic/lists/users_list.dart'; import 'package:comunic/lists/users_list.dart';
import 'package:comunic/models/api_request.dart'; import 'package:comunic/models/api_request.dart';
import 'package:comunic/utils/list_utils.dart'; import 'package:comunic/utils/api_utils.dart';
/// Search helper /// Search helper
/// ///
/// @author Pierre HUBERT /// @author Pierre HUBERT
class SearchHelper { class SearchHelper {
/// Search for user. This method returns information about the target users /// Search for user. This method returns information about the target users
/// ///
/// Returns information about the target users or null if an error occurred /// Returns information about the target users or null if an error occurred
Future<UsersList> searchUser(String query) async { Future<UsersList> searchUser(String query) async {
// Execute the query on the server // Execute the query on the server
final response = await APIRequest( final response = await APIRequest(
uri: "user/search", uri: "user/search", needLogin: true, args: {"query": query}).exec();
needLogin: true,
args: {
"query": query
}
).exec();
if (response.code != 200) return null; if (response.code != 200) return null;
return await UsersHelper().getUsersInfo( return await UsersHelper()
listToIntList(response.getArray())); .getUsersInfo(response.getArray().map((f) => cast<int>(f)).toList());
} }
} }