Fix an integration error when bibl present without citations

This commit is contained in:
Adomas Venčkauskas 2018-01-22 13:26:36 +02:00
parent 553d2b00d8
commit d41c8d6489

View file

@ -837,7 +837,7 @@ Zotero.Integration.Fields.prototype.get = new function() {
}; };
} }
} else if(topic === "fields-error") { } else if(topic === "fields-error") {
deferred.reject(e); deferred.reject(data);
deferred = null; deferred = null;
} }
}, QueryInterface:XPCOMUtils.generateQI([Components.interfaces.nsIObserver, Components.interfaces.nsISupports])}); }, QueryInterface:XPCOMUtils.generateQI([Components.interfaces.nsIObserver, Components.interfaces.nsISupports])});
@ -912,6 +912,8 @@ Zotero.Integration.Fields.prototype._processFields = Zotero.Promise.coroutine(fu
if (this._bibliographyFields.length) { if (this._bibliographyFields.length) {
this._session.bibliography = new Zotero.Integration.Bibliography(this._bibliographyFields[0]); this._session.bibliography = new Zotero.Integration.Bibliography(this._bibliographyFields[0]);
yield this._session.bibliography.loadItemData(); yield this._session.bibliography.loadItemData();
} else {
delete this._session.bibliography;
} }
// TODO: figure this out // TODO: figure this out
// Zotero.Notifier.trigger('add', 'collection', 'document'); // Zotero.Notifier.trigger('add', 'collection', 'document');
@ -991,10 +993,11 @@ Zotero.Integration.Fields.prototype._updateDocument = async function(forceCitati
var isRich = false; var isRich = false;
if (!citation.properties.dontUpdate) { if (!citation.properties.dontUpdate) {
var formattedCitation = citation.properties.formattedCitation && citation.properties.custom var formattedCitation = citation.properties.custom
? citation.properties.custom : citation.text; ? citation.properties.custom : citation.text;
var plainCitation = citation.properties.plainCitation && citationField.getText(); var plainCitation = citation.properties.plainCitation && citationField.getText();
// Update citation text:
// If we're not specifically *not* trying to regen text // If we're not specifically *not* trying to regen text
if (forceCitations != FORCE_CITATIONS_FALSE if (forceCitations != FORCE_CITATIONS_FALSE
// Or metadata has changed thus changing the formatted citation // Or metadata has changed thus changing the formatted citation