Skip to content

Commit

Permalink
Postcard Claim Online (#1376)
Browse files Browse the repository at this point in the history
* Claim postcard online

* Update Asset

* Update Text
  • Loading branch information
ppupha authored Nov 14, 2023
1 parent a4f9875 commit b111c01
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion assets
6 changes: 5 additions & 1 deletion lib/service/deeplink_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import 'package:autonomy_flutter/service/remote_config_service.dart';
import 'package:autonomy_flutter/service/tezos_beacon_service.dart';
import 'package:autonomy_flutter/service/wc2_service.dart';
import 'package:autonomy_flutter/util/constants.dart';
import 'package:autonomy_flutter/util/dio_exception_ext.dart';
import 'package:autonomy_flutter/util/log.dart';
import 'package:autonomy_flutter/util/string_ext.dart';
import 'package:collection/collection.dart';
Expand Down Expand Up @@ -637,7 +638,10 @@ class DeeplinkServiceImpl extends DeeplinkService {
);
} catch (e) {
log.info('[DeeplinkService] _handleClaimEmptyPostcardDeeplink error $e');

if (e is DioException && e.isPostcardClaimEmptyLimited) {
unawaited(_navigationService.showPostcardClaimLimited());
return;
}
if (otp == null) {
_navigationService.showPostcardRunOut();
} else {
Expand Down
7 changes: 7 additions & 0 deletions lib/service/navigation_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,13 @@ class NavigationService {
}
}

Future<void> showPostcardClaimLimited() async {
if (navigatorKey.currentContext != null &&
navigatorKey.currentState?.mounted == true) {
await UIHelper.showPostcardClaimLimited(navigatorKey.currentContext!);
}
}

Future<void> openAutonomyDocument(String href, String title) async {
if (navigatorKey.currentContext != null &&
navigatorKey.currentState?.mounted == true) {
Expand Down
9 changes: 9 additions & 0 deletions lib/util/dio_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import 'package:autonomy_flutter/common/environment.dart';
import 'package:autonomy_flutter/util/dio_exception_ext.dart';
import 'package:autonomy_flutter/util/dio_interceptors.dart';
import 'package:autonomy_flutter/util/isolated_util.dart';
import 'package:autonomy_flutter/util/log.dart';
Expand All @@ -23,6 +24,7 @@ Dio feralFileDio(BaseOptions options) {
Dio postcardDio(BaseOptions options) {
final dio = baseDio(options);
dio.interceptors.add(HmacAuthInterceptor(Environment.auClaimSecretKey));
dio.interceptors.add(AutonomyAuthInterceptor());
return dio;
}

Expand Down Expand Up @@ -54,6 +56,13 @@ Dio baseDio(BaseOptions options) {
logPrint: (message) {
log.warning("[request retry] $message");
},
retryEvaluator: (error, attempt) {
if (error.isPostcardClaimEmptyLimited) {
return false;
}
return true;
},
ignoreRetryEvaluatorExceptions: true,
retryDelays: const [
// set delays between retries
Duration(seconds: 1),
Expand Down
2 changes: 1 addition & 1 deletion lib/util/ui_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,7 @@ class UIHelper {
];
await showAutoDismissDialog(context, showDialog: () async {
return showPostcardDrawerAction(context, options: options);
}, autoDismissAfter: const Duration(seconds: 2));
}, autoDismissAfter: const Duration(seconds: 3));
}

static Future<void> _showPostcardInfo(BuildContext context,
Expand Down

0 comments on commit b111c01

Please sign in to comment.