Show message on OATH add account failure.

This commit is contained in:
Dain Nilsson 2022-04-05 13:02:11 +02:00
parent 479b9bc9c1
commit 2efbad0501
No known key found for this signature in database
GPG Key ID: F04367096FBA95E8

View File

@ -4,6 +4,7 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart';
import '../../app/message.dart';
import '../../app/state.dart';
@ -14,6 +15,8 @@ import '../models.dart';
import '../state.dart';
import 'utils.dart';
final _log = Logger('oath.view.add_account_page');
final _secretFormatterPattern =
RegExp('[abcdefghijklmnopqrstuvwxyz234567 ]', caseSensitive: false);
@ -340,7 +343,7 @@ class _OathAddAccountPageState extends ConsumerState<OathAddAccountPage> {
actions: [
TextButton(
onPressed: isValid
? () {
? () async {
if (secretLengthValid) {
final issuer = _issuerController.text;
@ -354,12 +357,17 @@ class _OathAddAccountPageState extends ConsumerState<OathAddAccountPage> {
period: period,
);
ref
.read(
credentialListProvider(widget.devicePath).notifier)
.addAccount(cred.toUri(), requireTouch: _touch);
Navigator.of(context).pop();
showMessage(context, 'Account added');
try {
await ref
.read(credentialListProvider(widget.devicePath)
.notifier)
.addAccount(cred.toUri(), requireTouch: _touch);
Navigator.of(context).pop();
showMessage(context, 'Account added');
} catch (e) {
_log.severe('Failed to add account', e);
showMessage(context, 'Failed adding account');
}
} else {
setState(() {
_validateSecretLength = true;