Skip to content

Commit

Permalink
Refactor error handling in PiContainerApi and improve UI responsivene…
Browse files Browse the repository at this point in the history
…ss in add container dialog
  • Loading branch information
frankmer committed Dec 18, 2024
1 parent e8dc042 commit 17d2f2f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
7 changes: 6 additions & 1 deletion lib/api/impl/privacy_idea_container_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,12 @@ class PiContainerApi implements TokenContainerApi {

final piResponse = response.asPiServerResponse<UnregisterContainerResult>();
final errorResponse = piResponse?.asError;
if (errorResponse != null) throw errorResponse.piServerResultError;
if (errorResponse != null) {
if (errorResponse.piServerResultError.code == 3002) {
return UnregisterContainerResult(success: true);
}
throw errorResponse.piServerResultError;
}
if (response.statusCode != 200 || piResponse == null) throw ResponseError(response);

return piResponse.asSuccess!.resultValue;
Expand Down
3 changes: 0 additions & 3 deletions lib/model/token_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,6 @@ class TokenContainer with _$TokenContainer {
return null;
}

Logger.warning('PublicServerKey: $publicServerKey'); // TODO: remove
Logger.warning('PublicClientKey: $publicClientKey'); // TODO: remove
Logger.warning('PrivateClientKey: $privateClientKey'); // TODO: remove
return TokenContainerFinalized(
issuer: issuer,
nonce: nonce,
Expand Down
20 changes: 11 additions & 9 deletions lib/widgets/dialog_widgets/add_container_progress_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,17 @@ class _AddContainerProgressDialogState extends State<AddContainerProgressDialog>
title: Text(AppLocalizations.of(context)!.containerAddDialogTitle),
content: SizedBox(
width: double.maxFinite,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: [
for (var serial in widget.serials) ...[
AddContainerProgressDialogTile(serial, _notifiers[serial]),
if (serial != widget.serials.last) const Divider(),
]
],
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: [
for (var serial in widget.serials) ...[
AddContainerProgressDialogTile(serial, _notifiers[serial]),
if (serial != widget.serials.last) const Divider(),
]
],
),
),
),
actions: [
Expand Down
2 changes: 1 addition & 1 deletion test/unit_test/api/privacy_idea_container_api_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ void _testPrivacyIdeaContainerApi() {
});
// Act
print('');
final data = await containerApi.finalizeContainer(tokenContainer, EccUtils());
final data = await containerApi.finalizeContainer(tokenContainer);
final policies = data.policies;
final responsePublicServerKey = data.publicServerKey;
// Assert
Expand Down

0 comments on commit 17d2f2f

Please sign in to comment.