diff options
author | zero-24 <zero-24@users.noreply.github.com> | 2019-02-01 20:22:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-01 20:22:19 +0100 |
commit | ce74e0901034cf50978e05f745289a6a37e6ea0a (patch) | |
tree | f6b0fb3692d7972f4e9fbb4c96f4fee9c9bad2b2 /src | |
parent | b67e3852573831a9956f0523ed11d7fd8451617d (diff) |
Add uncategorised group (Not grouped) on the app navigation #874
Diffstat (limited to 'src')
-rw-r--r-- | src/store/groups.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/store/groups.js b/src/store/groups.js index 8b00d593..4cef4140 100644 --- a/src/store/groups.js +++ b/src/store/groups.js @@ -35,7 +35,7 @@ const mutations = { extractGroupsFromContacts(state, contacts) { // iterate contacts contacts.forEach(contact => { - if (contact.groups) { + if (contact.groups.length != 0) { contact.groups.forEach(groupName => { let group = state.groups.find(search => search.name === groupName) // nothing? create a new one @@ -49,6 +49,20 @@ const mutations = { group.contacts.push(contact.key) }) } + else + { + let notGroupedName = t('contacts', 'Not grouped'); + let group = state.groups.find(search => search.name === notGroupedName) + // the group does not exists lets create it + if (!group) { + state.groups.push({ + name: notGroupedName, + contacts: [] + }) + group = state.groups.find(search => search.name === notGroupedName) + } + group.contacts.push(contact.key) + } }) }, |