forked from Henry-Hiles/nexus
Nicer verification error
This commit is contained in:
parent
3fff32f170
commit
095c72f983
2 changed files with 45 additions and 9 deletions
|
|
@ -82,7 +82,7 @@ class ClientController extends AsyncNotifier<int> {
|
|||
try {
|
||||
await sendCommand("verify", {"recovery_key": recoveryKey});
|
||||
return true;
|
||||
} catch (_) {
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -91,7 +91,7 @@ class ClientController extends AsyncNotifier<int> {
|
|||
try {
|
||||
await sendCommand("login", login.toJson());
|
||||
return true;
|
||||
} catch (_) {
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ class ClientController extends AsyncNotifier<int> {
|
|||
"user_id": "@fakeuser:${homeserver.host}",
|
||||
});
|
||||
return (response["m.homeserver"] as Map<String, dynamic>)["base_url"];
|
||||
} catch (_) {
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ class VerifyPage extends HookConsumerWidget {
|
|||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final passphraseController = useTextEditingController();
|
||||
final isVerifying = useState(false);
|
||||
return AlertDialog(
|
||||
title: Text("Verify"),
|
||||
content: Column(
|
||||
|
|
@ -32,12 +33,47 @@ class VerifyPage extends HookConsumerWidget {
|
|||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
ref
|
||||
.watch(ClientController.provider.notifier)
|
||||
.verify(passphraseController.text);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
onPressed: isVerifying.value
|
||||
? null
|
||||
: () async {
|
||||
final scaffoldMessenger = ScaffoldMessenger.of(context);
|
||||
final snackbar = scaffoldMessenger.showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
"Attempting to verify with recovery key...",
|
||||
),
|
||||
duration: Duration(days: 999),
|
||||
),
|
||||
);
|
||||
|
||||
isVerifying.value = true;
|
||||
|
||||
final success = await ref
|
||||
.watch(ClientController.provider.notifier)
|
||||
.verify(passphraseController.text);
|
||||
|
||||
snackbar.close();
|
||||
if (!success) {
|
||||
isVerifying.value = false;
|
||||
if (context.mounted) {
|
||||
scaffoldMessenger.showSnackBar(
|
||||
SnackBar(
|
||||
backgroundColor: Theme.of(
|
||||
context,
|
||||
).colorScheme.errorContainer,
|
||||
content: Text(
|
||||
"Verification failed. Is your passphrase correct?",
|
||||
style: TextStyle(
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.onErrorContainer,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
child: Text("Verify"),
|
||||
),
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue