From a4fd60ba4578dfac0c70c881b3af13cf8e83e4d3 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Thu, 30 Nov 2023 08:51:28 +0530 Subject: [PATCH 1/5] Extend generic errorDialog to surface more error --- lib/utils/dialog_util.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/utils/dialog_util.dart b/lib/utils/dialog_util.dart index b6fd7e533..acf49c0bf 100644 --- a/lib/utils/dialog_util.dart +++ b/lib/utils/dialog_util.dart @@ -1,4 +1,5 @@ import "package:dio/dio.dart"; +import "package:flutter/foundation.dart"; import 'package:flutter/material.dart'; import "package:flutter/services.dart"; import "package:photos/generated/l10n.dart"; @@ -72,12 +73,19 @@ Future showErrorDialogForException({ Future showGenericErrorDialog({ required BuildContext context, bool isDismissible = true, + Exception? error, + bool surfaceError = kDebugMode, }) async { + String errorBody = + S.of(context).itLooksLikeSomethingWentWrongPleaseRetryAfterSome; + if (surfaceError && error != null) { + errorBody = '$errorBody\n\n${error.toString()}'; + } return showDialogWidget( context: context, title: S.of(context).error, icon: Icons.error_outline_outlined, - body: S.of(context).itLooksLikeSomethingWentWrongPleaseRetryAfterSome, + body: errorBody, isDismissible: isDismissible, buttons: const [ ButtonWidget( From 7230d52dd25b24dab54069b5389627011e436abd Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Thu, 30 Nov 2023 10:37:38 +0530 Subject: [PATCH 2/5] ErrDialog: Surface network error & contact support --- lib/core/constants.dart | 2 + lib/generated/intl/messages_en.dart | 4 ++ lib/generated/l10n.dart | 20 ++++++ lib/l10n/intl_en.arb | 2 + lib/services/feature_flag_service.dart | 3 +- lib/services/user_service.dart | 10 +-- lib/utils/dialog_util.dart | 87 ++++++++++++++++++++++---- 7 files changed, 112 insertions(+), 16 deletions(-) diff --git a/lib/core/constants.dart b/lib/core/constants.dart index e0fe083cd..9ae2e8b66 100644 --- a/lib/core/constants.dart +++ b/lib/core/constants.dart @@ -64,3 +64,5 @@ const defaultRadiusValue = 40.0; const galleryGridSpacing = 2.0; const searchSectionLimit = 7; + +bool isInternalUser = false; diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index efac6e106..1326d41a5 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -869,6 +869,10 @@ class MessageLookup extends MessageLookupByLibrary { "movingFilesToAlbum": MessageLookupByLibrary.simpleMessage("Moving files to album..."), "name": MessageLookupByLibrary.simpleMessage("Name"), + "networkConnectionRefusedErr": MessageLookupByLibrary.simpleMessage( + "Unable to connect to Ente, please retry after sometime. If the error persists, please contact support."), + "networkHostLookUpErr": MessageLookupByLibrary.simpleMessage( + "Unable to connect to Ente, please check your network settings and contact support if the error persists."), "never": MessageLookupByLibrary.simpleMessage("Never"), "newAlbum": MessageLookupByLibrary.simpleMessage("New album"), "newToEnte": MessageLookupByLibrary.simpleMessage("New to ente"), diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index e0af479e3..9b05919d3 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -6529,6 +6529,26 @@ class S { ); } + /// `Unable to connect to Ente, please check your network settings and contact support if the error persists.` + String get networkHostLookUpErr { + return Intl.message( + 'Unable to connect to Ente, please check your network settings and contact support if the error persists.', + name: 'networkHostLookUpErr', + desc: '', + args: [], + ); + } + + /// `Unable to connect to Ente, please retry after sometime. If the error persists, please contact support.` + String get networkConnectionRefusedErr { + return Intl.message( + 'Unable to connect to Ente, please retry after sometime. If the error persists, please contact support.', + name: 'networkConnectionRefusedErr', + desc: '', + args: [], + ); + } + /// `Cached data` String get cachedData { return Intl.message( diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 18943691e..d38aef285 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -929,6 +929,8 @@ "itLooksLikeSomethingWentWrongPleaseRetryAfterSome": "It looks like something went wrong. Please retry after some time. If the error persists, please contact our support team.", "error": "Error", "tempErrorContactSupportIfPersists": "It looks like something went wrong. Please retry after some time. If the error persists, please contact our support team.", + "networkHostLookUpErr" : "Unable to connect to Ente, please check your network settings and contact support if the error persists.", + "networkConnectionRefusedErr" : "Unable to connect to Ente, please retry after sometime. If the error persists, please contact support.", "cachedData": "Cached data", "clearCaches": "Clear caches", "remoteImages": "Remote images", diff --git a/lib/services/feature_flag_service.dart b/lib/services/feature_flag_service.dart index 6899d99ed..0a630eb42 100644 --- a/lib/services/feature_flag_service.dart +++ b/lib/services/feature_flag_service.dart @@ -71,9 +71,10 @@ class FeatureFlagService { bool isInternalUserOrDebugBuild() { final String? email = Configuration.instance.getEmail(); final userID = Configuration.instance.getUserID(); - return (email != null && email.endsWith("@ente.io")) || + isInternalUser = (email != null && email.endsWith("@ente.io")) || _internalUserIDs.contains(userID) || kDebugMode; + return isInternalUser; } Future fetchFeatureFlags() async { diff --git a/lib/services/user_service.dart b/lib/services/user_service.dart index 6fb418aae..c5b14a305 100644 --- a/lib/services/user_service.dart +++ b/lib/services/user_service.dart @@ -127,12 +127,14 @@ class UserService { ), ); } else { - unawaited(showGenericErrorDialog(context: context)); + unawaited(showGenericErrorDialog(context: context, error: e)); } - } catch (e) { + } catch (e, s) { await dialog.hide(); - _logger.severe(e); - unawaited(showGenericErrorDialog(context: context)); + _logger.severe(e, s); + unawaited( + showGenericErrorDialog(context: context, error: e), + ); } } diff --git a/lib/utils/dialog_util.dart b/lib/utils/dialog_util.dart index acf49c0bf..066848789 100644 --- a/lib/utils/dialog_util.dart +++ b/lib/utils/dialog_util.dart @@ -2,6 +2,7 @@ import "package:dio/dio.dart"; import "package:flutter/foundation.dart"; import 'package:flutter/material.dart'; import "package:flutter/services.dart"; +import "package:photos/core/constants.dart"; import "package:photos/generated/l10n.dart"; import 'package:photos/models/button_result.dart'; import 'package:photos/models/typedefs.dart'; @@ -12,6 +13,7 @@ import 'package:photos/ui/components/action_sheet_widget.dart'; import 'package:photos/ui/components/buttons/button_widget.dart'; import 'package:photos/ui/components/dialog_widget.dart'; import 'package:photos/ui/components/models/button_type.dart'; +import "package:photos/utils/email_util.dart"; typedef DialogBuilder = DialogWidget Function(BuildContext context); @@ -69,32 +71,95 @@ Future showErrorDialogForException({ ); } +String parseErrorForUI( + BuildContext context, + String genericError, { + Object? error, + bool surfaceError = kDebugMode, +}) { + if (error == null) { + return genericError; + } + if (error is DioError) { + final DioError dioError = error; + if (dioError.type == DioErrorType.other) { + if (dioError.error.toString().contains('Failed host lookup')) { + return S.of(context).networkHostLookUpErr; + } else if (dioError.error.toString().contains('SocketException')) { + return S.of(context).networkConnectionRefusedErr; + } + } + } + // return generic error if the user is not internal and the error is not in debug mode + if (!(isInternalUser && kDebugMode)) { + return genericError; + } + String errorInfo = ""; + if (error is DioError) { + final DioError dioError = error; + if (dioError.type == DioErrorType.response) { + if (dioError.response?.data["code"] != null) { + errorInfo = "Reason: " + dioError.response!.data["code"]; + } else { + errorInfo = "Reason: " + dioError.response!.data.toString(); + } + } else if (dioError.type == DioErrorType.other) { + errorInfo = "Reason: " + dioError.error.toString(); + } else { + errorInfo = "Reason: " + dioError.type.toString(); + } + } else if (!kDebugMode) { + errorInfo = error.toString(); + } else { + errorInfo = error.toString().split('Source stack')[0]; + } + if (errorInfo.isNotEmpty) { + return "$genericError\n\n$errorInfo"; + } + return genericError; +} + ///Will return null if dismissed by tapping outside Future showGenericErrorDialog({ required BuildContext context, bool isDismissible = true, - Exception? error, - bool surfaceError = kDebugMode, + Object? error, }) async { - String errorBody = - S.of(context).itLooksLikeSomethingWentWrongPleaseRetryAfterSome; - if (surfaceError && error != null) { - errorBody = '$errorBody\n\n${error.toString()}'; - } - return showDialogWidget( + final errorBody = parseErrorForUI( + context, + S.of(context).itLooksLikeSomethingWentWrongPleaseRetryAfterSome, + error: error, + ); + + final ButtonResult? result = await showDialogWidget( context: context, title: S.of(context).error, icon: Icons.error_outline_outlined, body: errorBody, isDismissible: isDismissible, - buttons: const [ + buttons: [ + ButtonWidget( + buttonType: ButtonType.primary, + labelText: S.of(context).ok, + buttonAction: ButtonAction.first, + isInAlert: true, + ), ButtonWidget( buttonType: ButtonType.secondary, - labelText: "OK", - isInAlert: true, + labelText: S.of(context).contactSupport, + buttonAction: ButtonAction.second, + onTap: () async { + await sendLogs( + context, + S.of(context).contactSupport, + "support@ente.io", + postShare: () {}, + ); + }, ), ], ); + return result; } DialogWidget choiceDialog({ From 6780a3409c19ad45eb6962202d124117a9988b4f Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Thu, 30 Nov 2023 10:38:15 +0530 Subject: [PATCH 3/5] Simplify condition --- lib/utils/dialog_util.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/utils/dialog_util.dart b/lib/utils/dialog_util.dart index 066848789..0cb267b9c 100644 --- a/lib/utils/dialog_util.dart +++ b/lib/utils/dialog_util.dart @@ -108,8 +108,6 @@ String parseErrorForUI( } else { errorInfo = "Reason: " + dioError.type.toString(); } - } else if (!kDebugMode) { - errorInfo = error.toString(); } else { errorInfo = error.toString().split('Source stack')[0]; } From 1ec2b14df2d505065d32c1afb140ed9375b1ddf9 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Thu, 30 Nov 2023 10:49:35 +0530 Subject: [PATCH 4/5] Make error field mandatory --- lib/models/search/search_types.dart | 2 +- lib/services/billing_service.dart | 2 +- lib/services/hidden_service.dart | 2 +- lib/services/user_service.dart | 9 ++++---- lib/ui/account/delete_account_page.dart | 4 ++-- lib/ui/account/password_entry_page.dart | 6 ++--- lib/ui/account/verify_recovery_page.dart | 4 ++-- .../collection/collection_file_actions.dart | 4 ++-- .../collection_sharing_actions.dart | 14 ++++++------ lib/ui/actions/file/file_actions.dart | 2 +- lib/ui/collections/album/vertical_list.dart | 14 +++++++----- lib/ui/collections/new_album_icon.dart | 2 +- lib/ui/components/buttons/button_widget.dart | 2 +- lib/ui/home/memories/full_screen_memory.dart | 2 +- lib/ui/payment/child_subscription_widget.dart | 2 +- lib/ui/payment/payment_web_page.dart | 5 ++++- lib/ui/payment/store_subscription_page.dart | 11 ++++++---- lib/ui/payment/stripe_subscription_page.dart | 2 +- .../backup/backup_folder_selection_page.dart | 2 +- .../backup/backup_section_widget.dart | 4 ++-- lib/ui/settings/security_section_widget.dart | 22 +++++++++++++------ lib/ui/sharing/manage_album_participant.dart | 2 +- lib/ui/sharing/manage_links_widget.dart | 2 +- .../pickers/device_limit_picker_page.dart | 2 +- .../pickers/link_expiry_picker_page.dart | 2 +- lib/ui/viewer/file/file_app_bar.dart | 6 ++--- lib/ui/viewer/gallery/empty_album_state.dart | 2 +- .../gallery/gallery_app_bar_widget.dart | 14 ++++++------ lib/ui/viewer/location/location_screen.dart | 2 +- .../viewer/location/radius_picker_widget.dart | 2 +- lib/utils/delete_file_util.dart | 18 ++++++++++----- lib/utils/dialog_util.dart | 2 +- lib/utils/magic_util.dart | 2 +- lib/utils/share_util.dart | 2 +- 34 files changed, 100 insertions(+), 75 deletions(-) diff --git a/lib/models/search/search_types.dart b/lib/models/search/search_types.dart index dc15bc1ae..189569e2e 100644 --- a/lib/models/search/search_types.dart +++ b/lib/models/search/search_types.dart @@ -222,7 +222,7 @@ extension SectionTypeExtensions on SectionType { }, ); if (result is Exception) { - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: result); } }; default: diff --git a/lib/services/billing_service.dart b/lib/services/billing_service.dart index 6891089e3..5b5c57258 100644 --- a/lib/services/billing_service.dart +++ b/lib/services/billing_service.dart @@ -196,7 +196,7 @@ class BillingService { ); } catch (e) { await dialog.hide(); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); } await dialog.hide(); } diff --git a/lib/services/hidden_service.dart b/lib/services/hidden_service.dart index 97c21af24..a90dbc037 100644 --- a/lib/services/hidden_service.dart +++ b/lib/services/hidden_service.dart @@ -154,7 +154,7 @@ extension HiddenService on CollectionsService { } catch (e, s) { _logger.severe("Could not hide", e, s); await dialog.hide(); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); return false; } finally { await dialog.hide(); diff --git a/lib/services/user_service.dart b/lib/services/user_service.dart index c5b14a305..954891fd3 100644 --- a/lib/services/user_service.dart +++ b/lib/services/user_service.dart @@ -113,8 +113,9 @@ class UserService { ), ); return; + } else { + throw Exception("send-ott action failed, non-200"); } - unawaited(showGenericErrorDialog(context: context)); } on DioError catch (e) { await dialog.hide(); _logger.info(e); @@ -261,7 +262,7 @@ class UserService { //to close and only then to show the error dialog. Future.delayed( const Duration(milliseconds: 150), - () => showGenericErrorDialog(context: context), + () => showGenericErrorDialog(context: context, error: null), ); } } @@ -281,7 +282,7 @@ class UserService { } } catch (e) { _logger.severe(e); - await showGenericErrorDialog(context: context); + await showGenericErrorDialog(context: context, error: e); return null; } } @@ -958,7 +959,7 @@ class UserService { try { recoveryKey = await getOrCreateRecoveryKey(context); } catch (e) { - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); return false; } final dialog = createProgressDialog(context, S.of(context).verifying); diff --git a/lib/ui/account/delete_account_page.dart b/lib/ui/account/delete_account_page.dart index 9c1ecdfd1..8d031deed 100644 --- a/lib/ui/account/delete_account_page.dart +++ b/lib/ui/account/delete_account_page.dart @@ -262,7 +262,7 @@ class _DeleteAccountPageState extends State { isDismissible: false, ); if (choice!.action == ButtonAction.error) { - await showGenericErrorDialog(context: context); + await showGenericErrorDialog(context: context, error: choice.exception); } } @@ -289,7 +289,7 @@ class _DeleteAccountPageState extends State { showShortToast(context, S.of(context).yourAccountHasBeenDeleted); } catch (e, s) { Logger("DeleteAccount").severe("failed to delete", e, s); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); } } diff --git a/lib/ui/account/password_entry_page.dart b/lib/ui/account/password_entry_page.dart index f148ef21e..5da5cd03a 100644 --- a/lib/ui/account/password_entry_page.dart +++ b/lib/ui/account/password_entry_page.dart @@ -404,7 +404,7 @@ class _PasswordEntryPageState extends State { } catch (e, s) { _logger.severe(e, s); await dialog.hide(); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); } } @@ -456,7 +456,7 @@ class _PasswordEntryPageState extends State { } catch (e, s) { _logger.severe(e, s); await dialog.hide(); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); } } @@ -481,7 +481,7 @@ class _PasswordEntryPageState extends State { S.of(context).sorryWeCouldNotGenerateSecureKeysOnThisDevicennplease, ); } else { - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); } } } diff --git a/lib/ui/account/verify_recovery_page.dart b/lib/ui/account/verify_recovery_page.dart index baca1a987..c22aee355 100644 --- a/lib/ui/account/verify_recovery_page.dart +++ b/lib/ui/account/verify_recovery_page.dart @@ -51,7 +51,7 @@ class _VerifyRecoveryPageState extends State { "Please check your internet connection and try again.", ); } else { - await showGenericErrorDialog(context: context); + await showGenericErrorDialog(context: context, error: e); } return; } @@ -109,7 +109,7 @@ class _VerifyRecoveryPageState extends State { ), ); } catch (e) { - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); return; } } diff --git a/lib/ui/actions/collection/collection_file_actions.dart b/lib/ui/actions/collection/collection_file_actions.dart index b89f44b80..c46003b20 100644 --- a/lib/ui/actions/collection/collection_file_actions.dart +++ b/lib/ui/actions/collection/collection_file_actions.dart @@ -73,7 +73,7 @@ extension CollectionFileActions on CollectionActions { ); if (actionResult?.action != null && actionResult!.action == ButtonAction.error) { - showGenericErrorDialog(context: bContext); + showGenericErrorDialog(context: bContext, error: actionResult.exception); } else { selectedFiles.clearAll(); } @@ -187,7 +187,7 @@ extension CollectionFileActions on CollectionActions { } catch (e, s) { logger.severe("Failed to add to album", e, s); await dialog?.hide(); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); rethrow; } } diff --git a/lib/ui/actions/collection/collection_sharing_actions.dart b/lib/ui/actions/collection/collection_sharing_actions.dart index 970189c31..f4656fe15 100644 --- a/lib/ui/actions/collection/collection_sharing_actions.dart +++ b/lib/ui/actions/collection/collection_sharing_actions.dart @@ -52,7 +52,7 @@ class CollectionActions { _showUnSupportedAlert(context); } else { logger.severe("Failed to update shareUrl collection", e); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); } return false; } @@ -93,7 +93,7 @@ class CollectionActions { ); if (actionResult?.action != null) { if (actionResult!.action == ButtonAction.error) { - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: actionResult.exception); } return actionResult.action == ButtonAction.first; } else { @@ -142,7 +142,7 @@ class CollectionActions { return collection; } catch (e, s) { dialog.hide(); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); logger.severe("Failing to create link for selected files", e, s); } return null; @@ -183,7 +183,7 @@ class CollectionActions { ); if (actionResult?.action != null) { if (actionResult!.action == ButtonAction.error) { - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: actionResult.exception); } return actionResult.action == ButtonAction.first; } @@ -230,7 +230,7 @@ class CollectionActions { } catch (e) { await dialog?.hide(); logger.severe("Failed to get public key", e); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); return false; } // getPublicKey can return null when no user is associated with given @@ -272,7 +272,7 @@ class CollectionActions { _showUnSupportedAlert(context); } else { logger.severe("failed to share collection", e); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); } return false; } @@ -353,7 +353,7 @@ class CollectionActions { ); if (actionResult?.action != null && actionResult!.action == ButtonAction.error) { - showGenericErrorDialog(context: bContext); + showGenericErrorDialog(context: bContext, error: actionResult.exception); return false; } if ((actionResult?.action != null) && diff --git a/lib/ui/actions/file/file_actions.dart b/lib/ui/actions/file/file_actions.dart index 147c6ba23..695c53406 100644 --- a/lib/ui/actions/file/file_actions.dart +++ b/lib/ui/actions/file/file_actions.dart @@ -125,7 +125,7 @@ Future showSingleFileDeleteSheet( ); if (actionResult?.action != null && actionResult!.action == ButtonAction.error) { - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: actionResult.exception); } } diff --git a/lib/ui/collections/album/vertical_list.dart b/lib/ui/collections/album/vertical_list.dart index f95b1c2ac..c926c8b66 100644 --- a/lib/ui/collections/album/vertical_list.dart +++ b/lib/ui/collections/album/vertical_list.dart @@ -111,6 +111,7 @@ class AlbumVerticalListWidget extends StatelessWidget { if (result is Exception) { showGenericErrorDialog( context: context, + error: result, ); _logger.severe( "Failed to name album", @@ -310,7 +311,7 @@ class AlbumVerticalListWidget extends StatelessWidget { ); return true; } catch (e) { - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); return false; } } @@ -333,7 +334,7 @@ class AlbumVerticalListWidget extends StatelessWidget { ), ); } else { - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: result); _logger.severe("Cannot share collections owned by others"); } } @@ -352,7 +353,10 @@ class AlbumVerticalListWidget extends StatelessWidget { ), ); } else { - showGenericErrorDialog(context: context); + showGenericErrorDialog( + context: context, + error: Exception("Can not share collection owned by others"), + ); _logger.severe("Cannot share collections owned by others"); } return Future.value(true); @@ -409,7 +413,7 @@ class AlbumVerticalListWidget extends StatelessWidget { } catch (e, s) { _logger.severe("Could not move to album", e, s); await dialog.hide(); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); return false; } } @@ -438,7 +442,7 @@ class AlbumVerticalListWidget extends StatelessWidget { } catch (e, s) { _logger.severe("Could not move to album", e, s); await dialog.hide(); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); return false; } } diff --git a/lib/ui/collections/new_album_icon.dart b/lib/ui/collections/new_album_icon.dart index dddf81cf5..966685cd1 100644 --- a/lib/ui/collections/new_album_icon.dart +++ b/lib/ui/collections/new_album_icon.dart @@ -55,7 +55,7 @@ class NewAlbumIcon extends StatelessWidget { }, ); if (result is Exception) { - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: result); } }, ); diff --git a/lib/ui/components/buttons/button_widget.dart b/lib/ui/components/buttons/button_widget.dart index 63054bca3..ed6e53165 100644 --- a/lib/ui/components/buttons/button_widget.dart +++ b/lib/ui/components/buttons/button_widget.dart @@ -498,7 +498,7 @@ class _ButtonChildWidgetState extends State { } else if (exception != null) { //This is to show the execution was unsuccessful if the dialog is manually //closed before the execution completes. - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: exception); } } } diff --git a/lib/ui/home/memories/full_screen_memory.dart b/lib/ui/home/memories/full_screen_memory.dart index 8ead1ad69..7fb2a330d 100644 --- a/lib/ui/home/memories/full_screen_memory.dart +++ b/lib/ui/home/memories/full_screen_memory.dart @@ -36,7 +36,7 @@ class _FullScreenMemoryState extends State { bool _showCounter = false; bool _showStepIndicator = true; PageController? _pageController; - bool _shouldDisableScroll = false; + final bool _shouldDisableScroll = false; late int currentUserID; final GlobalKey shareButtonKey = GlobalKey(); diff --git a/lib/ui/payment/child_subscription_widget.dart b/lib/ui/payment/child_subscription_widget.dart index d9826021a..2b61d3cf9 100644 --- a/lib/ui/payment/child_subscription_widget.dart +++ b/lib/ui/payment/child_subscription_widget.dart @@ -123,7 +123,7 @@ class ChildSubscriptionWidget extends StatelessWidget { }, ); if (choice!.action == ButtonAction.error) { - await showGenericErrorDialog(context: context); + await showGenericErrorDialog(context: context, error: choice.exception); } } } diff --git a/lib/ui/payment/payment_web_page.dart b/lib/ui/payment/payment_web_page.dart index a5cd71a9e..5bba834d5 100644 --- a/lib/ui/payment/payment_web_page.dart +++ b/lib/ui/payment/payment_web_page.dart @@ -190,7 +190,10 @@ class _PaymentWebPageState extends State { } else { // should never reach here _logger.severe("unexpected status", uri.toString()); - showGenericErrorDialog(context: context); + showGenericErrorDialog( + context: context, + error: Exception("expected payment status $paymentStatus"), + ); } } diff --git a/lib/ui/payment/store_subscription_page.dart b/lib/ui/payment/store_subscription_page.dart index 722d6d5d2..abeeb8b12 100644 --- a/lib/ui/payment/store_subscription_page.dart +++ b/lib/ui/payment/store_subscription_page.dart @@ -524,11 +524,14 @@ class _StoreSubscriptionPageState extends State { final ProductDetailsResponse response = await InAppPurchase.instance.queryProductDetails({productID}); if (response.notFoundIDs.isNotEmpty) { - _logger.severe( - "Could not find products: " + response.notFoundIDs.toString(), - ); + final errMsg = "Could not find products: " + + response.notFoundIDs.toString(); + _logger.severe(errMsg); await _dialog.hide(); - showGenericErrorDialog(context: context); + showGenericErrorDialog( + context: context, + error: Exception(errMsg), + ); return; } final isCrossGradingOnAndroid = Platform.isAndroid && diff --git a/lib/ui/payment/stripe_subscription_page.dart b/lib/ui/payment/stripe_subscription_page.dart index e205fb062..d7354ba22 100644 --- a/lib/ui/payment/stripe_subscription_page.dart +++ b/lib/ui/payment/stripe_subscription_page.dart @@ -337,7 +337,7 @@ class _StripeSubscriptionPageState extends State { ).then((value) => onWebPaymentGoBack); } catch (e) { await _dialog.hide(); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); } await _dialog.hide(); } diff --git a/lib/ui/settings/backup/backup_folder_selection_page.dart b/lib/ui/settings/backup/backup_folder_selection_page.dart index f20dc48bb..810e1ee13 100644 --- a/lib/ui/settings/backup/backup_folder_selection_page.dart +++ b/lib/ui/settings/backup/backup_folder_selection_page.dart @@ -232,7 +232,7 @@ class _BackupFolderSelectionPageState extends State { } catch (e, s) { _logger.severe("Failed to updated backup folder", e, s); await dialog.hide(); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); } } diff --git a/lib/ui/settings/backup/backup_section_widget.dart b/lib/ui/settings/backup/backup_section_widget.dart index 2ecefe848..7b05da8bc 100644 --- a/lib/ui/settings/backup/backup_section_widget.dart +++ b/lib/ui/settings/backup/backup_section_widget.dart @@ -94,7 +94,7 @@ class BackupSectionWidgetState extends State { try { status = await SyncService.instance.getBackupStatus(); } catch (e) { - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); return; } @@ -128,7 +128,7 @@ class BackupSectionWidgetState extends State { duplicates = await DeduplicationService.instance.getDuplicateFiles(); } catch (e) { - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); return; } diff --git a/lib/ui/settings/security_section_widget.dart b/lib/ui/settings/security_section_widget.dart index 970cd3c80..7805167f9 100644 --- a/lib/ui/settings/security_section_widget.dart +++ b/lib/ui/settings/security_section_widget.dart @@ -89,7 +89,7 @@ class _SecuritySectionWidgetState extends State { try { recoveryKey = await _getOrCreateRecoveryKey(context); } catch (e) { - await showGenericErrorDialog(context: context); + await showGenericErrorDialog(context: context, error: e); return; } unawaited( @@ -260,14 +260,22 @@ class _SecuritySectionWidgetState extends State { await UserService.instance.getOrCreateRecoveryKey(context), ); } + Future updateEmailMFA(bool isEnabled) async { try { - final UserDetails details = await UserService.instance.getUserDetailsV2(memoryCount: false); - if((details.profileData?.canDisableEmailMFA ?? false) == false) { - await routeToPage(context, RequestPasswordVerificationPage(onPasswordVerified: (Uint8List keyEncryptionKey) async { - final Uint8List loginKey = await CryptoUtil.deriveLoginKey(keyEncryptionKey); - await UserService.instance.registerOrUpdateSrp(loginKey); - },),); + final UserDetails details = + await UserService.instance.getUserDetailsV2(memoryCount: false); + if ((details.profileData?.canDisableEmailMFA ?? false) == false) { + await routeToPage( + context, + RequestPasswordVerificationPage( + onPasswordVerified: (Uint8List keyEncryptionKey) async { + final Uint8List loginKey = + await CryptoUtil.deriveLoginKey(keyEncryptionKey); + await UserService.instance.registerOrUpdateSrp(loginKey); + }, + ), + ); } await UserService.instance.updateEmailMFA(isEnabled); } catch (e) { diff --git a/lib/ui/sharing/manage_album_participant.dart b/lib/ui/sharing/manage_album_participant.dart index f07d34f6e..7c6f33d56 100644 --- a/lib/ui/sharing/manage_album_participant.dart +++ b/lib/ui/sharing/manage_album_participant.dart @@ -132,7 +132,7 @@ class _ManageIndividualParticipantState CollectionParticipantRole.viewer, ); } catch (e) { - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); } if (isConvertToViewSuccess && mounted) { // reset value diff --git a/lib/ui/sharing/manage_links_widget.dart b/lib/ui/sharing/manage_links_widget.dart index 7377a8f68..846867029 100644 --- a/lib/ui/sharing/manage_links_widget.dart +++ b/lib/ui/sharing/manage_links_widget.dart @@ -347,7 +347,7 @@ class _ManageSharedLinkWidgetState extends State { } } catch (e) { await dialog?.hide(); - await showGenericErrorDialog(context: context); + await showGenericErrorDialog(context: context, error: e); rethrow; } } diff --git a/lib/ui/sharing/pickers/device_limit_picker_page.dart b/lib/ui/sharing/pickers/device_limit_picker_page.dart index ca7a89f4a..de409ad39 100644 --- a/lib/ui/sharing/pickers/device_limit_picker_page.dart +++ b/lib/ui/sharing/pickers/device_limit_picker_page.dart @@ -137,7 +137,7 @@ class _ItemsWidgetState extends State { try { await CollectionsService.instance.updateShareUrl(widget.collection, prop); } catch (e) { - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); rethrow; } } diff --git a/lib/ui/sharing/pickers/link_expiry_picker_page.dart b/lib/ui/sharing/pickers/link_expiry_picker_page.dart index 8ca0f5bf7..0e04e1a7f 100644 --- a/lib/ui/sharing/pickers/link_expiry_picker_page.dart +++ b/lib/ui/sharing/pickers/link_expiry_picker_page.dart @@ -180,7 +180,7 @@ class _ItemsWidgetState extends State { try { await CollectionsService.instance.updateShareUrl(widget.collection, prop); } catch (e) { - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); rethrow; } } diff --git a/lib/ui/viewer/file/file_app_bar.dart b/lib/ui/viewer/file/file_app_bar.dart index ebcc06c93..d52d8ed14 100644 --- a/lib/ui/viewer/file/file_app_bar.dart +++ b/lib/ui/viewer/file/file_app_bar.dart @@ -288,7 +288,7 @@ class FileAppBarState extends State { } } catch (e, s) { _logger.severe("failed to update file visibility", e, s); - await showGenericErrorDialog(context: context); + await showGenericErrorDialog(context: context, error: e); } } @@ -371,7 +371,7 @@ class FileAppBarState extends State { } catch (e) { _logger.warning("Failed to save file", e); await dialog.hide(); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); } finally { PhotoManager.startChangeNotify(); LocalSyncService.instance.checkAndSync().ignore(); @@ -432,7 +432,7 @@ class FileAppBarState extends State { } catch (e) { dialog.hide(); _logger.severe("Failed to use as", e); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); } } } diff --git a/lib/ui/viewer/gallery/empty_album_state.dart b/lib/ui/viewer/gallery/empty_album_state.dart index d8e985e59..0ec5b0756 100644 --- a/lib/ui/viewer/gallery/empty_album_state.dart +++ b/lib/ui/viewer/gallery/empty_album_state.dart @@ -31,7 +31,7 @@ class EmptyAlbumState extends StatelessWidget { try { await showAddPhotosSheet(context, c); } catch (e) { - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); } }, ), diff --git a/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/lib/ui/viewer/gallery/gallery_app_bar_widget.dart index b23780edf..a1dde81f1 100644 --- a/lib/ui/viewer/gallery/gallery_app_bar_widget.dart +++ b/lib/ui/viewer/gallery/gallery_app_bar_widget.dart @@ -172,7 +172,7 @@ class _GalleryAppBarWidgetState extends State { }, ); if (result is Exception) { - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: result); } } @@ -204,7 +204,7 @@ class _GalleryAppBarWidgetState extends State { ); if (actionResult?.action != null && mounted) { if (actionResult!.action == ButtonAction.error) { - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: actionResult.exception); } else if (actionResult.action == ButtonAction.first) { Navigator.of(context).pop(); } @@ -224,7 +224,7 @@ class _GalleryAppBarWidgetState extends State { .getBackupStatus(pathID: widget.deviceCollection!.id); } catch (e) { await dialog.hide(); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); return; } @@ -664,7 +664,7 @@ class _GalleryAppBarWidgetState extends State { } catch (e, s) { _logger.severe("failed to trash collection", e, s); await dialog.hide(); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); } } else { final bool result = await collectionActions.deleteCollectionSheet( @@ -691,7 +691,7 @@ class _GalleryAppBarWidgetState extends State { } } catch (e, s) { _logger.severe("failed to trash collection", e, s); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); } } @@ -726,7 +726,7 @@ class _GalleryAppBarWidgetState extends State { } } catch (e, s) { _logger.severe(e, s); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); } } @@ -736,7 +736,7 @@ class _GalleryAppBarWidgetState extends State { await showAddPhotosSheet(bContext, collection!); } catch (e, s) { _logger.severe(e, s); - showGenericErrorDialog(context: bContext); + showGenericErrorDialog(context: bContext, error: e); } } diff --git a/lib/ui/viewer/location/location_screen.dart b/lib/ui/viewer/location/location_screen.dart index 8e82a1991..5ff279288 100644 --- a/lib/ui/viewer/location/location_screen.dart +++ b/lib/ui/viewer/location/location_screen.dart @@ -118,7 +118,7 @@ class LocationScreenPopUpMenu extends StatelessWidget { ); Navigator.of(context).pop(); } catch (e) { - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); } } }, diff --git a/lib/ui/viewer/location/radius_picker_widget.dart b/lib/ui/viewer/location/radius_picker_widget.dart index 7d17437a4..d353340e3 100644 --- a/lib/ui/viewer/location/radius_picker_widget.dart +++ b/lib/ui/viewer/location/radius_picker_widget.dart @@ -200,7 +200,7 @@ class _RadiusPickerWidgetState extends State { alignMessage: Alignment.centerRight, ); if (result is Exception) { - await showGenericErrorDialog(context: context); + await showGenericErrorDialog(context: context, error: result); _logger.severe( "Failed to create custom radius", result, diff --git a/lib/utils/delete_file_util.dart b/lib/utils/delete_file_util.dart index c92210d89..1128887a2 100644 --- a/lib/utils/delete_file_util.dart +++ b/lib/utils/delete_file_util.dart @@ -102,7 +102,7 @@ Future deleteFilesFromEverywhere( await FilesDB.instance.deleteMultipleUploadedFiles(fileIDs); } catch (e) { _logger.severe(e); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); rethrow; } for (final collectionID in updatedCollectionIDs) { @@ -163,7 +163,7 @@ Future deleteFilesFromRemoteOnly( await FilesDB.instance.deleteMultipleUploadedFiles(uploadedFileIDs); } catch (e, s) { _logger.severe("Failed to delete files from remote", e, s); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); rethrow; } for (final collectionID in updatedCollectionIDs) { @@ -279,7 +279,10 @@ Future deleteFromTrash(BuildContext context, List files) async { actionResult!.action == ButtonAction.cancel) { return didDeletionStart ? true : false; } else if (actionResult.action == ButtonAction.error) { - await showGenericErrorDialog(context: context); + await showGenericErrorDialog( + context: context, + error: actionResult.exception, + ); return false; } else { return true; @@ -306,7 +309,10 @@ Future emptyTrash(BuildContext context) async { actionResult!.action == ButtonAction.cancel) { return false; } else if (actionResult.action == ButtonAction.error) { - await showGenericErrorDialog(context: context); + await showGenericErrorDialog( + context: context, + error: actionResult.exception, + ); return false; } else { return true; @@ -555,7 +561,7 @@ Future showDeleteSheet( showShortToast(context, S.of(context).movedToTrash); }, onError: (e, s) { - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: e); }, ); }, @@ -620,7 +626,7 @@ Future showDeleteSheet( ); if (actionResult?.action != null && actionResult!.action == ButtonAction.error) { - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: actionResult.exception); } else { selectedFiles.clearAll(); } diff --git a/lib/utils/dialog_util.dart b/lib/utils/dialog_util.dart index 0cb267b9c..80e69ed57 100644 --- a/lib/utils/dialog_util.dart +++ b/lib/utils/dialog_util.dart @@ -121,7 +121,7 @@ String parseErrorForUI( Future showGenericErrorDialog({ required BuildContext context, bool isDismissible = true, - Object? error, + required Object? error, }) async { final errorBody = parseErrorForUI( context, diff --git a/lib/utils/magic_util.dart b/lib/utils/magic_util.dart index 4c12af720..fc5fef9bc 100644 --- a/lib/utils/magic_util.dart +++ b/lib/utils/magic_util.dart @@ -218,7 +218,7 @@ Future editFilename( ); if (result is Exception) { _logger.severe("Failed to rename file"); - showGenericErrorDialog(context: context); + showGenericErrorDialog(context: context, error: result); } } diff --git a/lib/utils/share_util.dart b/lib/utils/share_util.dart index bcd18aa0d..c8750490f 100644 --- a/lib/utils/share_util.dart +++ b/lib/utils/share_util.dart @@ -74,7 +74,7 @@ Future share( s, ); await dialog.hide(); - await showGenericErrorDialog(context: context); + await showGenericErrorDialog(context: context, error: e); } } From 86da1196297de4f5c8106d9a9c11ed34b4d8adeb Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Thu, 30 Nov 2023 10:51:06 +0530 Subject: [PATCH 5/5] bump version 0.8.5+525 --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 98f2b9245..0eebd99a8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,7 +12,7 @@ description: ente photos application # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 0.8.4+524 +version: 0.8.5+525 environment: sdk: ">=3.0.0 <4.0.0"