chore: Better error message when join room failed
This commit is contained in:
parent
325431c8f6
commit
5fc75ac307
3 changed files with 13 additions and 7 deletions
|
|
@ -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."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ Future<Result<T>> showFutureLoadingDialog<T>({
|
|||
required Future<T> 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<Result<T>> showFutureLoadingDialog<T>({
|
|||
future: futureExec,
|
||||
title: title,
|
||||
backLabel: backLabel,
|
||||
onError: onError,
|
||||
exceptionContext: exceptionContext,
|
||||
),
|
||||
);
|
||||
return result ??
|
||||
|
|
@ -58,14 +58,14 @@ class LoadingDialog<T> extends StatefulWidget {
|
|||
final String? title;
|
||||
final String? backLabel;
|
||||
final Future<T> 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<T> createState() => LoadingDialogState<T>();
|
||||
|
|
@ -91,8 +91,7 @@ class LoadingDialogState<T> extends State<LoadingDialog> {
|
|||
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(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue