Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Remove warning while saving a new code

vishnukvmdf6d32e22f25b
diff --git a/lib/onboarding/view/setup_enter_secret_key_page.dart b/lib/onboarding/view/setup_enter_secret_key_page.dart
index d7d8c11d23..f2a2bf3a63 100644
--- a/lib/onboarding/view/setup_enter_secret_key_page.dart
+++ b/lib/onboarding/view/setup_enter_secret_key_page.dart
@@ -128,6 +128,10 @@ class _SetupEnterSecretKeyPageState extends State<SetupEnterSecretKeyPage> {
_showIncorrectDetailsDialog(context, message: message);
return;
}
+ if (widget.code == null) {
+ _saveCode();
+ return;
+ }
ButtonResult? result = await showChoiceActionSheet(
context,
title: context.l10n.warning,
@@ -139,28 +143,7 @@ class _SetupEnterSecretKeyPageState extends State<SetupEnterSecretKeyPage> {
if (result == null) return;
if (result.action == ButtonAction.first) {
- try {
- final account = _accountController.text.trim();
- final issuer = _issuerController.text.trim();
- final secret =
- _secretController.text.trim().replaceAll(' ', '');
- final Code newCode = widget.code == null
- ? Code.fromAccountAndSecret(
- account,
- issuer,
- secret,
- )
- : widget.code!.copyWith(
- account: account,
- issuer: issuer,
- secret: secret,
- );
- // Verify the validity of the code
- getOTP(newCode);
- Navigator.of(context).pop(newCode);
- } catch (e) {
- _showIncorrectDetailsDialog(context);
- }
+ _saveCode();
}
},
child: Padding(
@@ -180,6 +163,30 @@ class _SetupEnterSecretKeyPageState extends State<SetupEnterSecretKeyPage> {
);
}
+ void _saveCode() {
+ try {
+ final account = _accountController.text.trim();
+ final issuer = _issuerController.text.trim();
+ final secret = _secretController.text.trim().replaceAll(' ', '');
+ final Code newCode = widget.code == null
+ ? Code.fromAccountAndSecret(
+ account,
+ issuer,
+ secret,
+ )
+ : widget.code!.copyWith(
+ account: account,
+ issuer: issuer,
+ secret: secret,
+ );
+ // Verify the validity of the code
+ getOTP(newCode);
+ Navigator.of(context).pop(newCode);
+ } catch (e) {
+ _showIncorrectDetailsDialog(context);
+ }
+ }
+
void _showIncorrectDetailsDialog(
BuildContext context, {
String? message,