From 96639b970c1346516f6d44925a90719970fb8783 Mon Sep 17 00:00:00 2001 From: Dennis Fokin Date: Wed, 16 Aug 2023 13:42:15 +0200 Subject: [PATCH] Check capacity if state is not null --- lib/app/views/main_page.dart | 18 ------------------ lib/oath/views/add_multi_account_page.dart | 10 +++++++--- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/lib/app/views/main_page.dart b/lib/app/views/main_page.dart index 4f3e101e..023aac59 100755 --- a/lib/app/views/main_page.dart +++ b/lib/app/views/main_page.dart @@ -22,14 +22,11 @@ import '../../android/state.dart'; import '../../exception/cancellation_exception.dart'; import '../../core/state.dart'; import '../../fido/views/fido_screen.dart'; -import '../../oath/models.dart'; import '../../oath/state.dart'; -import '../../oath/views/add_account_page.dart'; import '../../oath/views/oath_screen.dart'; import '../../oath/views/utils.dart'; import '../../piv/views/piv_screen.dart'; import '../../widgets/custom_icons.dart'; -import '../message.dart'; import '../models.dart'; import '../state.dart'; import 'device_error_screen.dart'; @@ -101,7 +98,6 @@ class MainPage extends ConsumerWidget { icon: const Icon(Icons.person_add_alt_1), tooltip: l10n.s_add_account, onPressed: () async { - CredentialData? otpauth; final scanner = ref.read(qrScannerProvider); if (scanner != null) { try { @@ -115,20 +111,6 @@ class MainPage extends ConsumerWidget { return; } } - - await ref.read(withContextProvider)((context) => showBlurDialog( - context: context, - routeSettings: - const RouteSettings(name: 'oath_add_account'), - builder: (context) { - return OathAddAccountPage( - null, - null, - credentials: null, - credentialData: otpauth, - ); - }, - )); }, ), ); diff --git a/lib/oath/views/add_multi_account_page.dart b/lib/oath/views/add_multi_account_page.dart index 2dcea2d2..ca3fdb42 100644 --- a/lib/oath/views/add_multi_account_page.dart +++ b/lib/oath/views/add_multi_account_page.dart @@ -205,9 +205,13 @@ class _OathAddMultiAccountPageState bool isValid() { final credsToAdd = _credStates.values.where((element) => element.$1).length; - int? capacity = widget.state!.version.isAtLeast(4) ? 32 : null; - return (credsToAdd > 0) && - (capacity == null || (_numCreds! + credsToAdd <= capacity)); + if (widget.state != null) { + int? capacity = widget.state!.version.isAtLeast(4) ? 32 : null; + return (credsToAdd > 0) && + (capacity == null || (_numCreds! + credsToAdd <= capacity)); + } else { + return true; + } } void submit() async {