fix: validate group name

Signed-off-by: Dominik Kuzila <kuziladominik@gmail.com>
This commit is contained in:
Dominik Kužila
2024-10-27 20:36:32 +01:00
committed by Dominik Kuzila
parent f493e3662f
commit eb4ea50c8d
3 changed files with 11 additions and 3 deletions

View File

@ -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>

View File

@ -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

View File

@ -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)
},
}