Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mobile][photos] natively handle network disconnections in payment webview

r4khul60dd51618fbd
diff --git a/mobile/apps/photos/lib/ui/payment/payment_web_page.dart b/mobile/apps/photos/lib/ui/payment/payment_web_page.dart
index eb43e10f20..ea0c822ce1 100644
--- a/mobile/apps/photos/lib/ui/payment/payment_web_page.dart
+++ b/mobile/apps/photos/lib/ui/payment/payment_web_page.dart
@@ -96,8 +96,17 @@ class _PaymentWebPageState extends State<PaymentWebPage> {
onLoadStart: (controller, navigationAction) async {
_logger.info("onLoadStart $navigationAction");
},
- onReceivedError: (controller, navigationAction, code) async {
- _logger.severe("onLoadError $navigationAction $code");
+ onReceivedError: (controller, navigationAction, error) async {
+ _logger.severe("onLoadError $navigationAction $error");
+ if (navigationAction.isForMainFrame == true &&
+ error.type != WebResourceErrorType.CANCELLED) {
+ if (!mounted) return;
+ Navigator.of(context).pop(false);
+ await showGenericErrorDialog(
+ context: context,
+ error: error,
+ );
+ }
},
onReceivedHttpError:
(controller, navigationAction, code) async {
diff --git a/mobile/apps/photos/lib/utils/dialog_util.dart b/mobile/apps/photos/lib/utils/dialog_util.dart
index 1a645b20cd..401ebd4125 100644
--- a/mobile/apps/photos/lib/utils/dialog_util.dart
+++ b/mobile/apps/photos/lib/utils/dialog_util.dart
@@ -4,6 +4,7 @@ import "package:ente_strings/ente_strings.dart";
import "package:flutter/foundation.dart";
import 'package:flutter/material.dart';
import "package:flutter/services.dart";
+import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:photos/models/button_result.dart';
import 'package:photos/models/typedefs.dart';
import "package:photos/module/download/manager.dart";
@@ -125,6 +126,18 @@ String parseErrorForUI(
}
}
}
+
+ if (error is WebResourceError) {
+ if (error.type == WebResourceErrorType.HOST_LOOKUP ||
+ error.type == WebResourceErrorType.NOT_CONNECTED_TO_INTERNET ||
+ error.type == WebResourceErrorType.TIMEOUT) {
+ return context.strings.networkHostLookUpErr;
+ } else if (error.type == WebResourceErrorType.CANNOT_CONNECT_TO_HOST ||
+ error.type == WebResourceErrorType.SERVER_UNREACHABLE) {
+ return context.strings.networkConnectionRefusedErr;
+ }
+ }
+
// return generic error if the user is not internal and the error is not in debug mode
if (!(flagService.internalUser && kDebugMode)) {
return genericError;