1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-18 07:52:21 +01:00

Merge pull request #949 from owncloud/fix-js-error-on-delete

handle undefined contact
This commit is contained in:
Thomas Müller 2015-07-05 08:24:22 +02:00
commit 6f5dff84bf

View File

@ -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);