diff options
author | Dominik Kužila <dominik.kuzila@student.tuke.sk> | 2024-10-27 20:36:32 +0100 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2024-10-31 14:38:44 +0000 |
commit | 893b0ce59cc398cd1714964b526451365301e811 (patch) | |
tree | 2d7d47c112614f3e8b108f80dfeddcc733ffa182 | |
parent | fe6e9b0bf680a83035b93373184c1fe9cd8be2b4 (diff) |
fix: validate group namebackport/4197/stable6.1
Signed-off-by: Dominik Kuzila <kuziladominik@gmail.com>
-rw-r--r-- | AUTHORS.md | 1 | ||||
-rw-r--r-- | src/components/AppNavigation/RootNavigation.vue | 10 | ||||
-rw-r--r-- | src/store/groups.js | 3 |
3 files changed, 11 insertions, 3 deletions
@@ -9,6 +9,7 @@ - Christian Kraus <hanzi@hanzi.cc> - Christoph Wurst <christoph@winzerhof-wurst.at> - Daniel Kesselberg <mail@danielkesselberg.de> +- Dominik Kuzila <kuziladominik@gmail.com> - Gary Kim <gary@garykim.dev> - Georg Ehrke <oc.list@georgehrke.com> - Greta Doci <gretadoci@gmail.com> diff --git a/src/components/AppNavigation/RootNavigation.vue b/src/components/AppNavigation/RootNavigation.vue index 627fa9ff..c92d9c42 100644 --- a/src/components/AppNavigation/RootNavigation.vue +++ b/src/components/AppNavigation/RootNavigation.vue @@ -393,10 +393,14 @@ export default { this.createGroupError = null this.logger.debug('Created new local group', { groupName }) - this.$store.dispatch('addGroup', groupName) - this.isNewGroupMenuOpen = false - emit('contacts:group:append', groupName) + try { + this.$store.dispatch('addGroup', groupName) + this.isNewGroupMenuOpen = false + emit('contacts:group:append', groupName) + } catch (error) { + showError(t('contacts', 'An error occurred while creating the group')) + } }, // Ellipsis item toggles diff --git a/src/store/groups.js b/src/store/groups.js index 4da839e2..44de3e21 100644 --- a/src/store/groups.js +++ b/src/store/groups.js @@ -184,6 +184,9 @@ const actions = { * @param {string} groupName the name of the group */ addGroup(context, groupName) { + if (!groupName || groupName.trim() === '') { + throw new Error('Group name cannot be empty') + } context.commit('addGroup', groupName) }, } |