Update user service to accept both email and user IDs as input
This commit is contained in:
parent
c252e03185
commit
7e4519f9ef
2 changed files with 12 additions and 10 deletions
|
@ -47,15 +47,17 @@ class UserService {
|
|||
});
|
||||
}
|
||||
|
||||
Future<String> getPublicKey(BuildContext context, String email) async {
|
||||
final dialog = createProgressDialog(context, "Searching for user...");
|
||||
await dialog.show();
|
||||
Future<String> getPublicKey({String email, int userID}) async {
|
||||
final queryParams = Map<String, dynamic>();
|
||||
if (userID != null) {
|
||||
queryParams["userID"] = userID;
|
||||
} else {
|
||||
queryParams["email"] = email;
|
||||
}
|
||||
try {
|
||||
final response = await _dio.get(
|
||||
Configuration.instance.getHttpEndpoint() + "/users/public-key",
|
||||
queryParameters: {
|
||||
"email": email,
|
||||
},
|
||||
queryParameters: queryParams,
|
||||
options: Options(
|
||||
headers: {
|
||||
"X-Auth-Token": Configuration.instance.getToken(),
|
||||
|
@ -66,8 +68,6 @@ class UserService {
|
|||
} on DioError catch (e) {
|
||||
_logger.info(e);
|
||||
return null;
|
||||
} finally {
|
||||
await dialog.hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -146,8 +146,10 @@ class _SharingWidgetState extends State<SharingWidget> {
|
|||
"Please enter a valid email address");
|
||||
return;
|
||||
}
|
||||
|
||||
final publicKey = await UserService.instance.getPublicKey(context, _email);
|
||||
final dialog = createProgressDialog(context, "Searching for user...");
|
||||
await dialog.show();
|
||||
final publicKey = await UserService.instance.getPublicKey(email: _email);
|
||||
await dialog.hide();
|
||||
if (publicKey == null) {
|
||||
Navigator.of(context).pop();
|
||||
final dialog = AlertDialog(
|
||||
|
|
Loading…
Add table
Reference in a new issue