From 538bf0816028e27eeccb24f208239da68b8285f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Wed, 1 Jul 2015 13:30:11 +0200 Subject: [PATCH] handle undefined contact - fixes #948 --- js/contacts.js | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/js/contacts.js b/js/contacts.js index 19263c05..9e5772fa 100644 --- a/js/contacts.js +++ b/js/contacts.js @@ -15,17 +15,17 @@ OC.Contacts = OC.Contacts || {}; */ var Contact = function(parent, id, metadata, data, listtemplate, dragtemplate, fulltemplate, detailtemplates) { //console.log('contact:', id, metadata, data); //parent, id, data, listtemplate, fulltemplate); - this.parent = parent, - this.storage = parent.storage, - this.id = id, - this.metadata = metadata, - this.data = data, - this.$dragTemplate = dragtemplate, - this.$listTemplate = listtemplate, - this.$fullTemplate = fulltemplate; - this.detailTemplates = detailtemplates; - this.displayNames = {}; - this.sortOrder = contacts_sortby || 'fn'; + this.parent = parent; + this.storage = parent.storage; + this.id = id; + this.metadata = metadata; + this.data = data; + this.$dragTemplate = dragtemplate; + this.$listTemplate = listtemplate; + this.$fullTemplate = fulltemplate; + this.detailTemplates = detailtemplates; + this.displayNames = {}; + this.sortOrder = contacts_sortby || 'fn'; this.undoQueue = []; this.multi_properties = ['EMAIL', 'TEL', 'IMPP', 'ADR', 'URL', 'CLOUD']; }; @@ -2309,13 +2309,15 @@ OC.Contacts = OC.Contacts || {}; // Make a map of backends, address books and contacts for easier processing. do { contact = this.deletionQueue.shift(); - if(!contactMap[contact.getBackend()]) { - contactMap[contact.getBackend()] = {}; + if (!_.isUndefined(contact)) { + if(!contactMap[contact.getBackend()]) { + contactMap[contact.getBackend()] = {}; + } + if(!contactMap[contact.getBackend()][contact.getParent()]) { + contactMap[contact.getBackend()][contact.getParent()] = []; + } + contactMap[contact.getBackend()][contact.getParent()].push(contact.getId()); } - if(!contactMap[contact.getBackend()][contact.getParent()]) { - contactMap[contact.getBackend()][contact.getParent()] = []; - } - contactMap[contact.getBackend()][contact.getParent()].push(contact.getId()); } while(this.deletionQueue.length > 0); console.log('map', contactMap);