fix: Create chat dialog crashes sometimes and power level textfield does not validate input

This commit is contained in:
krille-chan 2023-10-28 10:09:40 +02:00
parent c29f9bd44a
commit 5665cac15c
No known key found for this signature in database
3 changed files with 16 additions and 5 deletions

View file

@ -2533,5 +2533,6 @@
"placeholders": {
"seconds": {}
}
}
},
"pleaseEnterANumber": "Please enter a number greater than 0"
}

View file

@ -34,7 +34,7 @@ class LoadProfileBottomSheet extends StatelessWidget {
@override
Widget build(BuildContext context) {
return FutureBuilder<ProfileInformation>(
future: Matrix.of(context)
future: Matrix.of(outerContext)
.client
.getUserProfile(userId)
.timeout(const Duration(seconds: 3)),
@ -138,7 +138,7 @@ class UserBottomSheetController extends State<UserBottomSheet> {
if (reason == null || reason.single.isEmpty) return;
final result = await showFutureLoadingDialog(
context: context,
future: () => Matrix.of(context).client.reportContent(
future: () => Matrix.of(widget.outerContext).client.reportContent(
user.roomId!,
user.eventId,
reason: reason.single,
@ -203,7 +203,7 @@ class UserBottomSheetController extends State<UserBottomSheet> {
case UserBottomSheetAction.message:
final roomIdResult = await showFutureLoadingDialog(
context: context,
future: () => Matrix.of(context)
future: () => Matrix.of(widget.outerContext)
.client
.startDirectChat(user?.id ?? widget.profile!.userId),
);
@ -215,7 +215,7 @@ class UserBottomSheetController extends State<UserBottomSheet> {
if (await askConfirmation()) {
await showFutureLoadingDialog(
context: context,
future: () => Matrix.of(context)
future: () => Matrix.of(widget.outerContext)
.client
.ignoreUser(user?.id ?? widget.profile!.userId),
);

View file

@ -61,6 +61,16 @@ Future<int?> showPermissionChooser(
initialText: currentLevel.toString(),
keyboardType: TextInputType.number,
autocorrect: false,
validator: (text) {
if (text == null) {
return L10n.of(context)!.pleaseEnterANumber;
}
final level = int.tryParse(text);
if (level == null || level < 0) {
return L10n.of(context)!.pleaseEnterANumber;
}
return null;
},
),
],
);