summaryrefslogtreecommitdiffstats
path: root/src/views
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-09-24 23:46:01 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-09-25 14:53:28 +0200
commitf3c1f13792d78e3617e3d3f726d1324f3ea576ee (patch)
tree29197f5d49c4cbc9c4d3bcf4d36fd25a2e09224f /src/views
parent19a56a6fba9ad82f9b0c34d92bb4cd256ae88a94 (diff)
Fixed select property
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src/views')
-rw-r--r--src/views/Contacts.vue51
1 files changed, 35 insertions, 16 deletions
diff --git a/src/views/Contacts.vue b/src/views/Contacts.vue
index f6117b49..245711f6 100644
--- a/src/views/Contacts.vue
+++ b/src/views/Contacts.vue
@@ -201,15 +201,18 @@ export default {
client.connect({ enableCardDAV: true }).then(() => {
console.debug('Connected to dav!', client)
this.$store.dispatch('getAddressbooks')
- .then(() => {
- // wait for all addressbooks to have fetch their contacts
- Promise.all(this.addressbooks.map(addressbook => this.$store.dispatch('getContactsFromAddressBook', { addressbook })))
- .then(results => {
- this.loading = false
- this.selectFirstContactIfNone()
- })
- // no need for a catch, the action does not throw
- // and the error is handled there
+ .then((addressbooks) => {
+
+ // No addressbooks? Create a new one!
+ if (addressbooks.length === 0) {
+ this.$store.dispatch('appendAddressbook', { displayName: t('contacts', 'Contacts') })
+ .then(() => {
+ this.fetchContacts()
+ })
+ // else, let's get those contacts!
+ } else {
+ this.fetchContacts()
+ }
})
// check local storage for orderKey
if (localStorage.getItem('orderKey')) {
@@ -240,13 +243,15 @@ export default {
contact.vCard.addPropertyWithValue('categories', this.selectedGroup)
}
this.$store.dispatch('addContact', contact)
- this.$router.push({
- name: 'contact',
- params: {
- selectedGroup: this.selectedGroup,
- selectedContact: contact.key
- }
- })
+ .then(() => {
+ this.$router.push({
+ name: 'contact',
+ params: {
+ selectedGroup: this.selectedGroup,
+ selectedContact: contact.key
+ }
+ })
+ })
},
/**
@@ -261,6 +266,20 @@ export default {
},
/**
+ * Fetch the contacts of each addressbooks
+ */
+ fetchContacts() {
+ // wait for all addressbooks to have fetch their contacts
+ Promise.all(this.addressbooks.map(addressbook => this.$store.dispatch('getContactsFromAddressBook', { addressbook })))
+ .then(results => {
+ this.loading = false
+ this.selectFirstContactIfNone()
+ })
+ // no need for a catch, the action does not throw
+ // and the error is handled there
+ },
+
+ /**
* Select the first contact of the list
* if none are selected already
*/