From 20ab1d75d2a5692823fc1b788714c07c8d3025ca Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Thu, 19 Oct 2023 11:54:23 +0530 Subject: [PATCH] Fix: Show confirmation during edit when secret is updated --- .../view/setup_enter_secret_key_page.dart | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/lib/onboarding/view/setup_enter_secret_key_page.dart b/lib/onboarding/view/setup_enter_secret_key_page.dart index f2a2bf3a6..ee46d7953 100644 --- a/lib/onboarding/view/setup_enter_secret_key_page.dart +++ b/lib/onboarding/view/setup_enter_secret_key_page.dart @@ -128,23 +128,7 @@ class _SetupEnterSecretKeyPageState extends State { _showIncorrectDetailsDialog(context, message: message); return; } - if (widget.code == null) { - _saveCode(); - return; - } - ButtonResult? result = await showChoiceActionSheet( - context, - title: context.l10n.warning, - body: context.l10n.confirmUpdatingkey, - firstButtonLabel: context.l10n.yes, - secondButtonAction: ButtonAction.cancel, - secondButtonLabel: context.l10n.cancel, - ); - - if (result == null) return; - if (result.action == ButtonAction.first) { - _saveCode(); - } + await _saveCode(); }, child: Padding( padding: const EdgeInsets.symmetric( @@ -163,11 +147,25 @@ class _SetupEnterSecretKeyPageState extends State { ); } - void _saveCode() { + Future _saveCode() async { try { final account = _accountController.text.trim(); final issuer = _issuerController.text.trim(); final secret = _secretController.text.trim().replaceAll(' ', ''); + if (widget.code != null && widget.code!.secret != secret) { + ButtonResult? result = await showChoiceActionSheet( + context, + title: context.l10n.warning, + body: context.l10n.confirmUpdatingkey, + firstButtonLabel: context.l10n.yes, + secondButtonAction: ButtonAction.cancel, + secondButtonLabel: context.l10n.cancel, + ); + if (result == null) return; + if (result.action != ButtonAction.first) { + return; + } + } final Code newCode = widget.code == null ? Code.fromAccountAndSecret( account,