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: validate group name #4197

Merged
merged 1 commit into from
Oct 31, 2024
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
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 @@

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'))
}

Check warning on line 403 in src/components/AppNavigation/RootNavigation.vue

View check run for this annotation

Codecov / codecov/patch

src/components/AppNavigation/RootNavigation.vue#L403

Added line #L403 was not covered by tests
},

// 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 @@
* @param {string} groupName the name of the group
*/
addGroup(context, groupName) {
if (!groupName || groupName.trim() === '') {
throw new Error('Group name cannot be empty')

Check warning on line 188 in src/store/groups.js

View check run for this annotation

Codecov / codecov/patch

src/store/groups.js#L188

Added line #L188 was not covered by tests
}
context.commit('addGroup', groupName)
},
}
Expand Down
Loading