Skip to content

Commit

Permalink
Merge pull request #4197 from Dominik-Kuzila/enhanc/validate-group-name
Browse files Browse the repository at this point in the history
fix: validate group name
  • Loading branch information
hamza221 authored Oct 31, 2024
2 parents c5a1d1f + eb4ea50 commit cbf8d94
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Christian Kraus <[email protected]>
- Christoph Wurst <[email protected]>
- Daniel Kesselberg <[email protected]>
- Dominik Kuzila <[email protected]>
- Gary Kim <[email protected]>
- Georg Ehrke <[email protected]>
- Greta Doci <[email protected]>
Expand Down
10 changes: 7 additions & 3 deletions src/components/AppNavigation/RootNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/store/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
}
Expand Down

0 comments on commit cbf8d94

Please sign in to comment.