Don't needlessly regenerate citation IDs
This commit is contained in:
parent
593153eebe
commit
387109c1da
|
@ -1187,6 +1187,7 @@ Zotero.Integration.Fields.prototype.addEditCitation = async function (field) {
|
||||||
}
|
}
|
||||||
let citationsPre = citations.slice(0, fieldToCitationIdxMapping[prevIdx]+1);
|
let citationsPre = citations.slice(0, fieldToCitationIdxMapping[prevIdx]+1);
|
||||||
let citationsPost = citations.slice(fieldToCitationIdxMapping[nextIdx]);
|
let citationsPost = citations.slice(fieldToCitationIdxMapping[nextIdx]);
|
||||||
|
let citationID = citation.citationID;
|
||||||
try {
|
try {
|
||||||
var result = this._session.style.previewCitationCluster(citation, citationsPre, citationsPost, "rtf");
|
var result = this._session.style.previewCitationCluster(citation, citationsPre, citationsPost, "rtf");
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
@ -1194,7 +1195,7 @@ Zotero.Integration.Fields.prototype.addEditCitation = async function (field) {
|
||||||
} finally {
|
} finally {
|
||||||
// CSL.previewCitationCluster() sets citationID, which means that we do not mark it
|
// CSL.previewCitationCluster() sets citationID, which means that we do not mark it
|
||||||
// as a new citation in Session.addCitation() if the ID is still present
|
// as a new citation in Session.addCitation() if the ID is still present
|
||||||
delete citation.citationID;
|
citation.citationID = citationID;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
@ -1575,7 +1576,7 @@ Zotero.Integration.Session.prototype.addCitation = Zotero.Promise.coroutine(func
|
||||||
// We need a new ID if there's another citation with the same citation ID in this document
|
// We need a new ID if there's another citation with the same citation ID in this document
|
||||||
var duplicateIndex = this.documentCitationIDs[citation.citationID];
|
var duplicateIndex = this.documentCitationIDs[citation.citationID];
|
||||||
var needNewID = !citation.citationID || duplicateIndex != undefined;
|
var needNewID = !citation.citationID || duplicateIndex != undefined;
|
||||||
if(needNewID || this.regenAll) {
|
if(needNewID) {
|
||||||
if (duplicateIndex != undefined) {
|
if (duplicateIndex != undefined) {
|
||||||
// If this is a duplicate, we need to mark both citations as "new"
|
// If this is a duplicate, we need to mark both citations as "new"
|
||||||
// since we do not know which one was the "original" one
|
// since we do not know which one was the "original" one
|
||||||
|
@ -1593,6 +1594,9 @@ Zotero.Integration.Session.prototype.addCitation = Zotero.Promise.coroutine(func
|
||||||
if (! this.oldCitations.has(citation.citationID) && !this.reload) {
|
if (! this.oldCitations.has(citation.citationID) && !this.reload) {
|
||||||
this.newIndices[index] = true;
|
this.newIndices[index] = true;
|
||||||
}
|
}
|
||||||
|
if (this.regenAll && !this.newIndices[index]) {
|
||||||
|
this.updateIndices[index] = true;
|
||||||
|
}
|
||||||
Zotero.debug("Integration: Adding citationID "+citation.citationID);
|
Zotero.debug("Integration: Adding citationID "+citation.citationID);
|
||||||
this.documentCitationIDs[citation.citationID] = index;
|
this.documentCitationIDs[citation.citationID] = index;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user