Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Show confirmation dialog when secrets are updated #299

Merged
merged 3 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions assets/custom-icons/_data/custom-icons.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"title": "Firefox"
},
{
"title": "GitHub"
"title": "GitHub",
"hex": "858585"
},
{
"title": "Google"
Expand Down Expand Up @@ -196,7 +197,8 @@
"slug": "x"
},
{
"title": "Ubisoft"
"title": "Ubisoft",
"hex": "4285f4"
},
{
"title": "Unity",
Expand Down
1 change: 1 addition & 0 deletions assets/custom-icons/icons/GitHub.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 0 additions & 5 deletions assets/custom-icons/icons/github.svg

This file was deleted.

6 changes: 1 addition & 5 deletions assets/custom-icons/icons/ubisoft.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 16 additions & 18 deletions lib/onboarding/view/setup_enter_secret_key_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,23 +128,7 @@ 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,
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(
Expand All @@ -163,11 +147,25 @@ class _SetupEnterSecretKeyPageState extends State<SetupEnterSecretKeyPage> {
);
}

void _saveCode() {
Future<void> _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,
Expand Down