Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions chrome/content/scripts/zoterocitationcounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,20 @@ Zotero.CitationCounts.init = function() {

Zotero.CitationCounts.notifierCallback = {
notify: function(event, type, ids, extraData) {
if (event == 'add') {
// This event is called when new items are added to zotero.
// There is a bug that this is also called when highlighting in the pdf viewer.
// For changes in the pdf viewer, the extraData format is different (doesn't have instanceID in the dictionary).
// Hack: based on the extraData format, decide if we want to call the citationCount.
const isCalledFromHiglight = ids[0] in extraData && 'instanceID' in extraData[ids[0]];

if (event == 'add' && !isCalledFromHiglight) {
// Another fix not to retrieve if extension is cancelled, based on https://github.com/eschnett/zotero-citationcounts/issues/16
const operation = getPref("autoretrieve");
Zotero.CitationCounts.updateItems(Zotero.Items.get(ids), operation);
if (operation != "none" || operation === undefined || operation == null ) {
Zotero.CitationCounts.updateItems(Zotero.Items.get(ids), operation);
} else {
return
}
}
}
};
Expand Down