Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

refactor: improve lifecycle management and error handling in user service

AmanRajSinghMouryad255f57c478c
diff --git a/mobile/packages/accounts/lib/pages/two_factor_authentication_page.dart b/mobile/packages/accounts/lib/pages/two_factor_authentication_page.dart
index 68e34cb067..1d9f8b3a9d 100644
--- a/mobile/packages/accounts/lib/pages/two_factor_authentication_page.dart
+++ b/mobile/packages/accounts/lib/pages/two_factor_authentication_page.dart
@@ -26,6 +26,7 @@ class _TwoFactorAuthenticationPageState
@override
void initState() {
+ super.initState();
_lifecycleEventHandler = LifecycleEventHandler(
resumeCallBack: () async {
if (mounted) {
@@ -40,7 +41,6 @@ class _TwoFactorAuthenticationPageState
WidgetsBinding.instance.addPostFrameCallback((_) {
_pinFocusNode.requestFocus();
});
- super.initState();
}
@override
diff --git a/mobile/packages/accounts/lib/services/user_service.dart b/mobile/packages/accounts/lib/services/user_service.dart
index 59db561c16..c51a960839 100644
--- a/mobile/packages/accounts/lib/services/user_service.dart
+++ b/mobile/packages/accounts/lib/services/user_service.dart
@@ -912,25 +912,7 @@ class UserService {
} on DioException catch (e) {
await dialog.hide();
_logger.severe(e);
- final dynamic data = e.response?.data;
- final String? enteErrCode =
- data is Map<String, dynamic> ? data["code"] as String? : null;
- if (enteErrCode != null &&
- enteErrCode == 'LOCKER_REGISTRATION_DISABLED') {
- // ignore: unawaited_futures
- showErrorDialog(
- context,
- context.strings.oops,
- context.strings.lockerExistingUserRequired,
- );
- } else if (enteErrCode != null && enteErrCode == 'LOCKER_ROLLOUT_LIMIT') {
- // ignore: unawaited_futures
- showErrorDialog(
- context,
- "We're out of beta seats for now",
- "This preview access has reached capacity. We'll be opening it to more users soon.",
- );
- } else if (e.response != null && e.response!.statusCode == 404) {
+ if (e.response != null && e.response!.statusCode == 404) {
showToast(context, "Session expired");
// ignore: unawaited_futures
Navigator.of(context).pushAndRemoveUntil(
@@ -943,20 +925,22 @@ class UserService {
);
} else {
// ignore: unawaited_futures
- showErrorDialog(
+ showAlertBottomSheet(
context,
- context.strings.incorrectCode,
- context.strings.authenticationFailedPleaseTryAgain,
+ title: context.strings.incorrectCode,
+ message: context.strings.authenticationFailedPleaseTryAgain,
+ assetPath: 'assets/warning-grey.png',
);
}
} catch (e) {
await dialog.hide();
_logger.severe(e);
// ignore: unawaited_futures
- showErrorDialog(
+ showAlertBottomSheet(
context,
- context.strings.oops,
- context.strings.authenticationFailedPleaseTryAgain,
+ title: context.strings.oops,
+ message: context.strings.authenticationFailedPleaseTryAgain,
+ assetPath: 'assets/warning-grey.png',
);
}
}