[mob][photos] Show custom error on ip mismatch
This commit is contained in:
parent
7c9160478d
commit
5c645d50f0
5 changed files with 48 additions and 6 deletions
|
@ -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();
|
||||
}
|
||||
|
|
4
mobile/lib/generated/intl/messages_en.dart
generated
4
mobile/lib/generated/intl/messages_en.dart
generated
|
@ -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"),
|
||||
|
|
20
mobile/lib/generated/l10n.dart
generated
20
mobile/lib/generated/l10n.dart
generated
|
@ -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> {
|
||||
|
|
|
@ -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."
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue