Skip to content

Commit

Permalink
Cover the field with _resetDriver
Browse files Browse the repository at this point in the history
  • Loading branch information
cormacrelf committed Dec 1, 2020
1 parent bad5615 commit 08b6dc4
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions chrome/content/zotero/xpcom/citeproc-rs-to-citeproc-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ Zotero.CiteprocRs = {
}

_insertCitationReferences(citation) {
if (!this._driver) {
this._resetDriver();
}
let cites = [];
for (const citationItem of citation.citationItems) {
let citeprocItem = this.sys.retrieveItem(citationItem.id);
Expand All @@ -118,6 +121,9 @@ Zotero.CiteprocRs = {
}

previewCitationCluster(citation, citationsPre, citationsPost, outputFormat) {
if (!this._driver) {
this._resetDriver();
}
if (!citation.citationID) citation.citationID = Zotero.Utilities.randomString(10);

let cites = this._insertCitationReferences(citation);
Expand All @@ -136,6 +142,9 @@ Zotero.CiteprocRs = {
}

insertCluster(citation) {
if (!this._driver) {
this._resetDriver();
}
let cluster = { id: citation.citationID };
cluster.cites = this._insertCitationReferences(citation);

Expand All @@ -145,12 +154,18 @@ Zotero.CiteprocRs = {
}

setClusterOrder(citations) {
if (!this._driver) {
this._resetDriver();
}
let clusters = this._getClusterOrder(citations);
Zotero.debug(`CiteprocRs: setClusterOrder ${JSON.stringify(clusters)}`, 5);
this._driver.setClusterOrder(clusters).unwrap();
}

getBatchedUpdates() {
if (!this._driver) {
this._resetDriver();
}
Zotero.debug(`CiteprocRs: batchedUpdates`, 5);
let updateSummary = this._driver.batchedUpdates().unwrap();
updateSummary.clusters = updateSummary.clusters.map(([id, output]) => {
Expand All @@ -171,6 +186,9 @@ Zotero.CiteprocRs = {
}

updateUncitedItems(itemIDs) {
if (!this._driver) {
this._resetDriver();
}
let referenceIDs = [];
for (let id of itemIDs) {
let citeprocItem = this.sys.retrieveItem(id);
Expand All @@ -184,6 +202,9 @@ Zotero.CiteprocRs = {
}

makeBibliography() {
if (!this._driver) {
this._resetDriver();
}
Zotero.debug(`CiteprocRs: bibliographyMeta`, 5);

// Converting from the wrongly documented citeproc-rs return format
Expand Down

0 comments on commit 08b6dc4

Please sign in to comment.