From 17aca346c6f5ba373f6a35d44fcfb4d5a2da3d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Tue, 30 Apr 2019 09:56:35 +0300 Subject: [PATCH] Fix wrongly shown error upon bibliography insertion (since 96d6114c) --- chrome/content/zotero/xpcom/integration.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index 9d15982ad0..871e2c46e7 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -1427,10 +1427,15 @@ Zotero.Integration.Session.prototype.init = Zotero.Promise.coroutine(function *( var data = this.data; var haveFields = false; + let fieldTypes = [this._app.primaryFieldType, this._app.secondaryFieldType]; + if (data.prefs.fieldType) { + fieldTypes = [data.prefs.fieldType]; + } + // If prefs not present - if (require && !data.prefs.fieldType) { + if (require) { // check to see if fields already exist - for (let fieldType of [this.primaryFieldType, this.secondaryFieldType]) { + for (let fieldType of fieldTypes) { var fields = yield this._doc.getFields(fieldType); if (fields.length) { haveFields = true; @@ -1439,13 +1444,13 @@ Zotero.Integration.Session.prototype.init = Zotero.Promise.coroutine(function *( } } - if (require && (!haveFields && data.prefs.fieldType)) { - // If required but no fields and preferences exist throw an error + if (require && !haveFields) { + // If required but no fields throw an error return Zotero.Promise.reject(new Zotero.Exception.Alert( - "integration.error.mustInsertCitation", - [], "integration.error.title")); - } else if (!data.prefs.fieldType) { - Zotero.debug("Integration: No document preferences found, but found "+data.prefs.fieldType+" fields"); + "integration.error.mustInsertCitation", + [], "integration.error.title")); + } + if (!data.prefs.fieldType) { // Unless explicitly disabled if (dontRunSetDocPrefs) return false;