summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--package.json1
-rw-r--r--src/store/addressbooks.js10
-rw-r--r--src/store/contacts.js2
-rw-r--r--src/views/Contacts.vue19
4 files changed, 19 insertions, 13 deletions
diff --git a/package.json b/package.json
index 16201c46..b61ca70e 100644
--- a/package.json
+++ b/package.json
@@ -65,7 +65,6 @@
"jest-serializer-vue": "^2.0.2",
"node-sass": "^4.9.3",
"prettier-eslint": "^8.8.2",
- "raw-loader": "^0.5.1",
"sass-loader": "^7.1.0",
"stylelint": "^8.4.0",
"stylelint-config-recommended-scss": "^3.2.0",
diff --git a/src/store/addressbooks.js b/src/store/addressbooks.js
index 55cc8cde..385b68ec 100644
--- a/src/store/addressbooks.js
+++ b/src/store/addressbooks.js
@@ -276,7 +276,7 @@ const actions = {
* @param {Object} importDetails = { vcf, addressbook }
*/
getContactsFromAddressBook(context, { addressbook }) {
- addressbook.dav.findAllAndFilterBySimpleProperties(['EMAIL', 'UID', 'CATEGORIES', 'FN', 'ORG'])
+ return addressbook.dav.findAllAndFilterBySimpleProperties(['EMAIL', 'UID', 'CATEGORIES', 'FN', 'ORG'])
.then((response) => {
// We don't want to lose the url information
// so we need to parse one by one
@@ -289,6 +289,14 @@ const actions = {
context.commit('appendContacts', contacts)
context.commit('appendGroupsFromContacts', contacts)
context.commit('sortContacts')
+ return contacts
+ })
+ .catch((error) => {
+ // unrecoverable error, if no contacts were loaded,
+ // remove the addressbook
+ // TODO: create a failed addressbook state and show that there was an issue?
+ context.commit('deleteAddressbook', addressbook)
+ console.error(error)
})
},
diff --git a/src/store/contacts.js b/src/store/contacts.js
index 8a6163e9..4b92e62f 100644
--- a/src/store/contacts.js
+++ b/src/store/contacts.js
@@ -22,9 +22,7 @@
import Vue from 'vue'
import ICAL from 'ical.js'
-
import Contact from '../models/contact'
-import client from '../services/cdav'
const state = {
// Using objects for performance
diff --git a/src/views/Contacts.vue b/src/views/Contacts.vue
index 13d86b09..f6117b49 100644
--- a/src/views/Contacts.vue
+++ b/src/views/Contacts.vue
@@ -26,14 +26,14 @@
<!-- new-contact-button + navigation + settings -->
<app-navigation :menu="menu">
<!-- settings -->
- <settings-section slot="settings-content" v-if="!loading" />
+ <settings-section v-if="!loading" slot="settings-content" />
</app-navigation>
<!-- main content -->
<div id="app-content">
<div id="app-content-wrapper">
<!-- loading -->
- <import-screen v-if="importState.stage != 'default'" />
+ <import-screen v-if="importState.stage !== 'default'" />
<template v-else>
<!-- contacts list -->
<content-list :list="contactsList" :contacts="contacts" :loading="loading" />
@@ -202,12 +202,14 @@ export default {
console.debug('Connected to dav!', client)
this.$store.dispatch('getAddressbooks')
.then(() => {
- Promise.all(this.addressbooks.map(async addressbook => {
- await this.$store.dispatch('getContactsFromAddressBook', { addressbook })
- })).then(() => {
- this.loading = false
- this.selectFirstContactIfNone()
- })
+ // 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
})
// check local storage for orderKey
if (localStorage.getItem('orderKey')) {
@@ -276,7 +278,6 @@ export default {
selectedContact: Object.values(this.contactsList)[0].key
}
})
- document.querySelector('.app-content-list-item.active').scrollIntoView()
}
}
}