Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Fix alert control type errors

Neeraj Gupta8f0fe8285af1
diff --git a/mobile/apps/photos/lib/ui/components/buttons/button_widget.dart b/mobile/apps/photos/lib/ui/components/buttons/button_widget.dart
index 187fe290c6..43220a0742 100644
--- a/mobile/apps/photos/lib/ui/components/buttons/button_widget.dart
+++ b/mobile/apps/photos/lib/ui/components/buttons/button_widget.dart
@@ -430,7 +430,7 @@ class _ButtonChildWidgetState extends State<ButtonChildWidget> {
},
onError: (error, stackTrace) {
executionState = ExecutionState.error;
- _exception = error as Exception;
+ _exception = error is Exception ? error : Exception(error.toString());
_debouncer.cancelDebounceTimer();
},
);
@@ -462,6 +462,7 @@ class _ButtonChildWidgetState extends State<ButtonChildWidget> {
? (widget.isInAlert ? 1 : 2)
: 0,
), () {
+ if (!mounted) return;
widget.isInAlert
? _popWithButtonAction(
context,
@@ -497,8 +498,10 @@ class _ButtonChildWidgetState extends State<ButtonChildWidget> {
if (widget.isInAlert) {
Future.delayed(
Duration(seconds: widget.shouldShowSuccessConfirmation ? 1 : 0),
- () =>
- _popWithButtonAction(context, buttonAction: widget.buttonAction),
+ () {
+ if (!mounted) return;
+ _popWithButtonAction(context, buttonAction: widget.buttonAction);
+ },
);
}
}
@@ -510,8 +513,10 @@ class _ButtonChildWidgetState extends State<ButtonChildWidget> {
Exception? exception,
}) {
if (mounted) {
- if (Navigator.of(context).canPop()) {
- Navigator.of(context).pop(ButtonResult(buttonAction, exception));
+ final route = ModalRoute.of(context);
+ final navigator = Navigator.of(context);
+ if (route is PopupRoute && route.isCurrent && navigator.canPop()) {
+ navigator.pop(ButtonResult(buttonAction, exception));
} else if (exception != null) {
//This is to show the execution was unsuccessful if the dialog is manually
//closed before the execution completes.
diff --git a/mobile/apps/photos/lib/ui/components/text_input_widget.dart b/mobile/apps/photos/lib/ui/components/text_input_widget.dart
index c0b40470bd..82865ee7e8 100644
--- a/mobile/apps/photos/lib/ui/components/text_input_widget.dart
+++ b/mobile/apps/photos/lib/ui/components/text_input_widget.dart
@@ -288,7 +288,7 @@ class _TextInputWidgetState extends State<TextInputWidget> {
} catch (e) {
executionState = ExecutionState.error;
_debouncer.cancelDebounceTimer();
- _exception = e as Exception;
+ _exception = e is Exception ? e : Exception(e.toString());
if (e.toString().contains("Incorrect password")) {
_logger.warning("Incorrect password");
_surfaceWrongPasswordState();
@@ -329,6 +329,7 @@ class _TextInputWidgetState extends State<TextInputWidget> {
? (widget.popNavAfterSubmission ? 1 : 2)
: 0,
), () {
+ if (!mounted) return;
widget.popNavAfterSubmission
? _popNavigatorStack(context)
: null;
@@ -357,7 +358,10 @@ class _TextInputWidgetState extends State<TextInputWidget> {
if (widget.popNavAfterSubmission) {
Future.delayed(
Duration(seconds: widget.alwaysShowSuccessState ? 1 : 0),
- () => _popNavigatorStack(context),
+ () {
+ if (!mounted) return;
+ _popNavigatorStack(context);
+ },
);
}
}