diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-08-28 18:27:58 +0200 |
---|---|---|
committer | suntala <suntala@hotmail.com> | 2018-08-28 20:54:16 +0200 |
commit | ec6ecc7863098198133379e240613e0253276ab5 (patch) | |
tree | 0856727b0293821bc39e126833324e6b3c37c329 /src/services/parseVcf.js | |
parent | 8850e9a3aeb637210cd4461e12b0dadc55d48857 (diff) |
Import progress work by @suntala
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src/services/parseVcf.js')
-rw-r--r-- | src/services/parseVcf.js | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/services/parseVcf.js b/src/services/parseVcf.js index 2a2039d5..86c02981 100644 --- a/src/services/parseVcf.js +++ b/src/services/parseVcf.js @@ -1,7 +1,7 @@ /** - * @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com> + * @copyright Copyright (c) 2018 Team Popcorn <teampopcornberlin@gmail.com> * - * @author John Molakvoæ <skjnldsv@protonmail.com> + * @author Team Popcorn <teampopcornberlin@gmail.com> * * @license GNU AGPL version 3 or any later version * @@ -22,19 +22,25 @@ import Contact from '../models/contact' -export default function parseVcf(data = '', addressbook) { +export default function parseVcf(data = '', addressbook, importState) { let regexp = /BEGIN:VCARD[\s\S]*?END:VCARD/mgi let vCards = data.match(regexp) + importState.total = vCards.length + if (!vCards) { console.debug('Error during the parsing of the following vcf file: ', data) return [] } return vCards.map(vCard => { try { - return new Contact(vCard, addressbook) + // console.log(vCards.indexOf(vCard)) + let contact = new Contact(vCard, addressbook) + importState.accepted++ + return contact } catch (e) { // Parse error! Do not stop here... + importState.denied++ // eslint-disable-next-line console.error(e) } |