YADESK-630 add account

This commit is contained in:
Adam Velebil 2022-04-07 10:41:38 +02:00
parent 52123644a7
commit 411d744537
No known key found for this signature in database
GPG Key ID: AC6D6B9D715FC084
2 changed files with 19 additions and 4 deletions

View File

@ -272,7 +272,7 @@ class MainViewModel : ViewModel() {
.toJson(session.deviceId)
.toString()
result.success(jsonResult)
returnSuccess(result, jsonResult)
}
}
} catch (cause: Throwable) {

View File

@ -177,9 +177,24 @@ class _AndroidCredentialListNotifier extends OathCredentialListNotifier {
await _api.addAccount(credentialUri.toString(), requireTouch);
var result = jsonDecode(resultString);
final pair = OathPair(OathCredential.fromJson(result['credential']),
result['code'] != null ? OathCode.fromJson(result['code']) : null);
refresh();
final newCredential = OathCredential.fromJson(result['credential']);
final newCode =
result['code'] != null ? OathCode.fromJson(result['code']) : null;
final pair = OathPair(newCredential, newCode);
if (mounted) {
final newState = state!.toList();
// this should not happen when adding a new credential
// but if we
final index = newState.indexWhere((e) => e.credential == newCredential);
if (index > 0) {
newState.removeAt(index);
}
newState.add(pair);
state = newState;
}
return pair.credential;
}