diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 6bba787fc..c8da22f32 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -2812,5 +2812,6 @@ "strikeThrough": "Strikethrough", "pleaseFillOut": "Please fill out", "invalidUrl": "Invalid url", - "addLink": "Add link" + "addLink": "Add link", + "unableToJoinChat": "Unable to join chat. Maybe the other party has already closed the conversation." } diff --git a/lib/utils/localized_exception_extension.dart b/lib/utils/localized_exception_extension.dart index 4716dcbdb..8bd493246 100644 --- a/lib/utils/localized_exception_extension.dart +++ b/lib/utils/localized_exception_extension.dart @@ -101,6 +101,11 @@ extension LocalizedExceptionExtension on Object { } if (this is String) return toString(); if (this is UiaException) return toString(); + + if (exceptionContext == ExceptionContext.joinRoom) { + return L10n.of(context).unableToJoinChat; + } + Logs().w('Something went wrong: ', this); return L10n.of(context).oopsSomethingWentWrong; } @@ -110,4 +115,5 @@ enum ExceptionContext { changePassword, checkHomeserver, checkServerSupportInfo, + joinRoom, } diff --git a/lib/widgets/future_loading_dialog.dart b/lib/widgets/future_loading_dialog.dart index 11b867dbf..4b5a44478 100644 --- a/lib/widgets/future_loading_dialog.dart +++ b/lib/widgets/future_loading_dialog.dart @@ -17,9 +17,9 @@ Future> showFutureLoadingDialog({ required Future Function() future, String? title, String? backLabel, - String Function(dynamic exception)? onError, bool barrierDismissible = false, bool delay = true, + ExceptionContext? exceptionContext, }) async { final futureExec = future(); final resultFuture = ResultFuture(futureExec); @@ -44,7 +44,7 @@ Future> showFutureLoadingDialog({ future: futureExec, title: title, backLabel: backLabel, - onError: onError, + exceptionContext: exceptionContext, ), ); return result ?? @@ -58,14 +58,14 @@ class LoadingDialog extends StatefulWidget { final String? title; final String? backLabel; final Future future; - final String Function(dynamic exception)? onError; + final ExceptionContext? exceptionContext; const LoadingDialog({ super.key, required this.future, this.title, - this.onError, this.backLabel, + this.exceptionContext, }); @override LoadingDialogState createState() => LoadingDialogState(); @@ -91,8 +91,7 @@ class LoadingDialogState extends State { Widget build(BuildContext context) { final exception = this.exception; final titleLabel = exception != null - ? widget.onError?.call(exception) ?? - exception.toLocalizedString(context) + ? exception.toLocalizedString(context, widget.exceptionContext) : widget.title ?? L10n.of(context).loadingPleaseWait; return AlertDialog.adaptive(