From 45f6492494d67cc53810e0cc44ee866ef6a8b68b Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 12 Jun 2019 23:43:48 -0400 Subject: [PATCH] Adjustments to citation retraction warning (#1704) - Fix don't-show-again checkbox for non-DB items - Tweak warning text - Don't show comma after year if year is missing (which it shouldn't be) - Remove redundant try/catch --- chrome/content/zotero/xpcom/integration.js | 22 +++++++++----------- chrome/locale/en-US/zotero/zotero.properties | 4 ++-- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index 15cb0a11ae..cfeb6d6e9a 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -971,7 +971,7 @@ Zotero.Integration.Fields.prototype.updateSession = Zotero.Promise.coroutine(fun yield this._session.handleRetractedItems(); } catch (e) { - Zotero.debug('Retracted item handling failed'); + Zotero.debug('Retracted item handling failed', 2); Zotero.logError(e); } this._session.regenAll = false; @@ -1939,7 +1939,8 @@ Zotero.Integration.Session.prototype.handleRetractedItems = async function () { const dealWithRetracted = (citedItem, inLibrary) => { let dontPromptAgain = this.promptForRetraction(citedItem, inLibrary); if (dontPromptAgain) { - for (let citation of this.citationsByItemID[citedItem.id]) { + let itemID = citedItem.id || citedItem.cslItemID; + for (let citation of this.citationsByItemID[itemID]) { for (let item of citation.citationItems) { item.ignoreRetraction = true; } @@ -1961,13 +1962,9 @@ Zotero.Integration.Session.prototype.handleRetractedItems = async function () { } } } - try { - var retractedIndices = await Zotero.Retractions.getRetractionsFromJSON( - embeddedZoteroItems.map(item => item.toJSON())); - } catch (e) { - Zotero.debug("Retraction for embedded docs lookup failed"); - Zotero.logError(e); - } + var retractedIndices = await Zotero.Retractions.getRetractionsFromJSON( + embeddedZoteroItems.map(item => item.toJSON()) + ); for (let index of retractedIndices) { dealWithRetracted(embeddedZoteroItems[index]); } @@ -1978,10 +1975,11 @@ Zotero.Integration.Session.prototype.promptForRetraction = function (citedItem, let buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_OK); // Cannot use citedItem.firstCreator since embedded items do not have that let creator = citedItem.getCreator(0); + let year = citedItem.getField('year'); let itemString = (creator ? creator.lastName + ", " : "") - + citedItem.getField('year') + ", " + + (year ? year + ", " : "") + citedItem.getDisplayTitle(); - let promptText = Zotero.getString('retraction.citedItemWarning') + let promptText = Zotero.getString('retraction.citationWarning') + "\n\n" + itemString; if (inLibrary) { @@ -1993,7 +1991,7 @@ Zotero.Integration.Session.prototype.promptForRetraction = function (citedItem, promptText, buttonFlags, null, null, null, - Zotero.getString('retraction.citedItemWarning.dontWarn'), checkbox); + Zotero.getString('retraction.citationWarning.dontWarn'), checkbox); return checkbox.value; } diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties index 23e6221716..483ff4574c 100644 --- a/chrome/locale/en-US/zotero/zotero.properties +++ b/chrome/locale/en-US/zotero/zotero.properties @@ -1211,5 +1211,5 @@ retraction.details = More details: retraction.credit = Data from %S retraction.citeWarning.text1 = The item you are citing has been retracted. Do you still want to add it to your document? retraction.citeWarning.text2 = You can view the item in your library for further details on the retraction. -retraction.citedItemWarning = A cited item in your document has been retracted: -retraction.citedItemWarning.dontWarn = Don’t warn me about this item again +retraction.citationWarning = A citation in your document has been retracted: +retraction.citationWarning.dontWarn = Don’t warn me about this citation again