From 3b3a790dcd20066f82e4acd19898d78669494511 Mon Sep 17 00:00:00 2001 From: olorin99 Date: Thu, 11 Dec 2025 18:24:38 +1000 Subject: [PATCH] Add check for renaming tag to already used tag. --- lib/l10n/app_en.arb | 1 + lib/src/widgets/tags/tag_editor.dart | 34 +++++++++++++++++++++------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 20069d5b..bbe891c3 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -13,6 +13,7 @@ "refreshAuth": "Refresh login", "totpToken": "TOTP Token (if needed)", "cancel": "Cancel", + "okay": "Okay", "rename": "Rename", "replace": "Replace", "continue_": "Continue", diff --git a/lib/src/widgets/tags/tag_editor.dart b/lib/src/widgets/tags/tag_editor.dart index c5b2f8c4..d98575b0 100644 --- a/lib/src/widgets/tags/tag_editor.dart +++ b/lib/src/widgets/tags/tag_editor.dart @@ -111,14 +111,32 @@ class _TagEditorState extends State { padding: const EdgeInsets.only(right: 8), child: FilledButton( onPressed: () async { - final tag = await ac.setTag( - Tag( - id: widget.tag.id, - tag: _tagController.text, - backgroundColor: _backgroundColor, - textColor: _textColor, - ), - ); + Tag tag; + try { + tag = await ac.setTag( + Tag( + id: widget.tag.id, + tag: _tagController.text, + backgroundColor: _backgroundColor, + textColor: _textColor, + ), + ); + } catch (err) { + if (!context.mounted) return; + await showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text(l(context).tags_exist), + actions: [ + OutlinedButton( + onPressed: () => Navigator.pop(context), + child: Text(l(context).okay), + ), + ], + ), + ); + return; + } widget.onUpdate(tag); if (!context.mounted) return; Navigator.pop(context);