π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Show custom error on ip mismatch
Neeraj Gupta5c645d50f052
diff --git a/mobile/lib/gateways/cast_gw.dart b/mobile/lib/gateways/cast_gw.dartindex fb342c1a90..63735d6782 100644--- a/mobile/lib/gateways/cast_gw.dart+++ b/mobile/lib/gateways/cast_gw.dart@@ -12,10 +12,14 @@ class CastGateway {);return response.data["publicKey"];} catch (e) {- if (e is DioError &&- e.response != null &&- e.response!.statusCode == 404) {- return null;+ if (e is DioError && e.response != null) {+ if (e.response!.statusCode == 404) {+ return null;+ } else if (e.response!.statusCode == 403) {+ throw CastIPMismatchException();+ } else {+ rethrow;+ }}rethrow;}@@ -48,3 +52,7 @@ class CastGateway {}}}++class CastIPMismatchException implements Exception {+ CastIPMismatchException();+}diff --git a/mobile/lib/generated/intl/messages_en.dart b/mobile/lib/generated/intl/messages_en.dartindex 265e4819b3..6c91e4c7c1 100644--- a/mobile/lib/generated/intl/messages_en.dart+++ b/mobile/lib/generated/intl/messages_en.dart@@ -394,6 +394,10 @@ class MessageLookup extends MessageLookupByLibrary {"cannotAddMorePhotosAfterBecomingViewer": m9,"cannotDeleteSharedFiles":MessageLookupByLibrary.simpleMessage("Cannot delete shared files"),+ "castIPMismatchBody": MessageLookupByLibrary.simpleMessage(+ "Please make sure you are on the same network as the TV."),+ "castIPMismatchTitle":+ MessageLookupByLibrary.simpleMessage("Failed to cast album"),"castInstruction": MessageLookupByLibrary.simpleMessage("Visit cast.ente.io on the device you want to pair.\n\nEnter the code below to play the album on your TV."),"centerPoint": MessageLookupByLibrary.simpleMessage("Center point"),diff --git a/mobile/lib/generated/l10n.dart b/mobile/lib/generated/l10n.dartindex a142fb78ec..0acdf14df1 100644--- a/mobile/lib/generated/l10n.dart+++ b/mobile/lib/generated/l10n.dart@@ -8663,6 +8663,26 @@ class S {args: [],);}++ /// `Failed to cast album`+ String get castIPMismatchTitle {+ return Intl.message(+ 'Failed to cast album',+ name: 'castIPMismatchTitle',+ desc: '',+ args: [],+ );+ }++ /// `Please make sure you are on the same network as the TV.`+ String get castIPMismatchBody {+ return Intl.message(+ 'Please make sure you are on the same network as the TV.',+ name: 'castIPMismatchBody',+ desc: '',+ args: [],+ );+ }}class AppLocalizationDelegate extends LocalizationsDelegate<S> {diff --git a/mobile/lib/l10n/intl_en.arb b/mobile/lib/l10n/intl_en.arbindex f365f50e86..dbfa1448c9 100644--- a/mobile/lib/l10n/intl_en.arb+++ b/mobile/lib/l10n/intl_en.arb@@ -1222,5 +1222,7 @@"autoCastiOSPermission": "Make sure Local Network permissions are turned on for the Ente Photos app, in Settings.","noDeviceFound": "No device found","stopCastingTitle": "Stop casting",- "stopCastingBody": "Do you want to stop casting?"+ "stopCastingBody": "Do you want to stop casting?",+ "castIPMismatchTitle": "Failed to cast album",+ "castIPMismatchBody": "Please make sure you are on the same network as the TV."}\ No newline at end of filediff --git a/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dartindex 0fc20ab1eb..c363ebd2e0 100644--- a/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart+++ b/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart@@ -948,7 +948,15 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {return true;} catch (e, s) {_logger.severe("Failed to cast album", e, s);- await showGenericErrorDialog(context: context, error: e);+ if (e is CastIPMismatchException) {+ await showErrorDialog(+ context,+ S.of(context).castIPMismatchTitle,+ S.of(context).castIPMismatchBody,+ );+ } else {+ await showGenericErrorDialog(context: context, error: e);+ }return false;}}