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",
|
"strikeThrough": "Strikethrough",
|
||||||
"pleaseFillOut": "Please fill out",
|
"pleaseFillOut": "Please fill out",
|
||||||
"invalidUrl": "Invalid url",
|
"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 String) return toString();
|
||||||
if (this is UiaException) return toString();
|
if (this is UiaException) return toString();
|
||||||
|
|
||||||
|
if (exceptionContext == ExceptionContext.joinRoom) {
|
||||||
|
return L10n.of(context).unableToJoinChat;
|
||||||
|
}
|
||||||
|
|
||||||
Logs().w('Something went wrong: ', this);
|
Logs().w('Something went wrong: ', this);
|
||||||
return L10n.of(context).oopsSomethingWentWrong;
|
return L10n.of(context).oopsSomethingWentWrong;
|
||||||
}
|
}
|
||||||
|
|
@ -110,4 +115,5 @@ enum ExceptionContext {
|
||||||
changePassword,
|
changePassword,
|
||||||
checkHomeserver,
|
checkHomeserver,
|
||||||
checkServerSupportInfo,
|
checkServerSupportInfo,
|
||||||
|
joinRoom,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@ Future<Result<T>> showFutureLoadingDialog<T>({
|
||||||
required Future<T> Function() future,
|
required Future<T> Function() future,
|
||||||
String? title,
|
String? title,
|
||||||
String? backLabel,
|
String? backLabel,
|
||||||
String Function(dynamic exception)? onError,
|
|
||||||
bool barrierDismissible = false,
|
bool barrierDismissible = false,
|
||||||
bool delay = true,
|
bool delay = true,
|
||||||
|
ExceptionContext? exceptionContext,
|
||||||
}) async {
|
}) async {
|
||||||
final futureExec = future();
|
final futureExec = future();
|
||||||
final resultFuture = ResultFuture(futureExec);
|
final resultFuture = ResultFuture(futureExec);
|
||||||
|
|
@ -44,7 +44,7 @@ Future<Result<T>> showFutureLoadingDialog<T>({
|
||||||
future: futureExec,
|
future: futureExec,
|
||||||
title: title,
|
title: title,
|
||||||
backLabel: backLabel,
|
backLabel: backLabel,
|
||||||
onError: onError,
|
exceptionContext: exceptionContext,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return result ??
|
return result ??
|
||||||
|
|
@ -58,14 +58,14 @@ class LoadingDialog<T> extends StatefulWidget {
|
||||||
final String? title;
|
final String? title;
|
||||||
final String? backLabel;
|
final String? backLabel;
|
||||||
final Future<T> future;
|
final Future<T> future;
|
||||||
final String Function(dynamic exception)? onError;
|
final ExceptionContext? exceptionContext;
|
||||||
|
|
||||||
const LoadingDialog({
|
const LoadingDialog({
|
||||||
super.key,
|
super.key,
|
||||||
required this.future,
|
required this.future,
|
||||||
this.title,
|
this.title,
|
||||||
this.onError,
|
|
||||||
this.backLabel,
|
this.backLabel,
|
||||||
|
this.exceptionContext,
|
||||||
});
|
});
|
||||||
@override
|
@override
|
||||||
LoadingDialogState<T> createState() => LoadingDialogState<T>();
|
LoadingDialogState<T> createState() => LoadingDialogState<T>();
|
||||||
|
|
@ -91,8 +91,7 @@ class LoadingDialogState<T> extends State<LoadingDialog> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final exception = this.exception;
|
final exception = this.exception;
|
||||||
final titleLabel = exception != null
|
final titleLabel = exception != null
|
||||||
? widget.onError?.call(exception) ??
|
? exception.toLocalizedString(context, widget.exceptionContext)
|
||||||
exception.toLocalizedString(context)
|
|
||||||
: widget.title ?? L10n.of(context).loadingPleaseWait;
|
: widget.title ?? L10n.of(context).loadingPleaseWait;
|
||||||
|
|
||||||
return AlertDialog.adaptive(
|
return AlertDialog.adaptive(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue