diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-01-05 10:42:47 +0100 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-01-05 10:42:47 +0100 |
commit | 59508f8659c9253e0c6d07689337d65746be9130 (patch) | |
tree | fca52e4b64c3ac498ef57f3917ee07adda8e999f /src/store | |
parent | f408f6e4a1a443ddcf5cc5a59a7148f63479e064 (diff) |
Remove contact from group^on contat deletion
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src/store')
-rw-r--r-- | src/store/contacts.js | 1 | ||||
-rw-r--r-- | src/store/groups.js | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/store/contacts.js b/src/store/contacts.js index 8cb8f496..da47e067 100644 --- a/src/store/contacts.js +++ b/src/store/contacts.js @@ -258,6 +258,7 @@ const actions = { } context.commit('deleteContact', contact) context.commit('deleteContactFromAddressbook', contact) + context.commit('removeContactFromGroups', contact) }, /** diff --git a/src/store/groups.js b/src/store/groups.js index e6cfd4e1..8b00d593 100644 --- a/src/store/groups.js +++ b/src/store/groups.js @@ -89,6 +89,21 @@ const mutations = { if (index > -1) { contacts.splice(index, 1) } + }, + + /** + * Remove contact from its groups + * + * @param {Object} state the store data + * @param {Contact} contact the contact + */ + removeContactFromGroups(state, contact) { + state.groups.forEach(group => { + const index = group.contacts.indexOf(contact.key) + if (index !== -1) { + group.contacts.splice(index, 1) + } + }) } } @@ -111,6 +126,16 @@ const actions = { }, /** + * Remove contact from its groups + * + * @param {Object} context the store mutations + * @param {Contact} contact the contact + */ + removeContactFromGroups(context, contact) { + context.commit('removeContactFromGroups', contact) + }, + + /** * Remove contact from group * * @param {Object} context the store mutations |