qf: fix breakage with unloaded tab (#5347)
Properly load all item data for items opened in tabs
to account for the fact that they can belong to
libraries that are not yet loaded.
Similar fix as in 4421de63de
This commit is contained in:
parent
4cc52ec928
commit
3aef6cddcb
1 changed files with 14 additions and 5 deletions
|
@ -656,13 +656,22 @@ var Zotero_QuickFormat = new function () {
|
|||
}).map(t => t.data.itemID);
|
||||
if (!itemIDs.length) return [];
|
||||
|
||||
let items = itemIDs.map((itemID) => {
|
||||
let item = Zotero.Items.get(itemID);
|
||||
// Fetch top-most items and load necessary data, in case tabs belong to an unloaded library
|
||||
let items = [];
|
||||
for (let itemID of itemIDs) {
|
||||
let item = await Zotero.Items.getAsync(itemID);
|
||||
if (item && item.parentItemID) {
|
||||
itemID = item.parentItemID;
|
||||
item = await Zotero.Items.getAsync(item.parentItemID);
|
||||
}
|
||||
return Zotero.Cite.getItem(itemID);
|
||||
});
|
||||
// Ignore tabs from libraries that are not specified
|
||||
if (io.filterLibraryIDs) {
|
||||
let itemInLibrary = io.filterLibraryIDs.some(id => id === item.libraryID);
|
||||
if (!itemInLibrary) continue;
|
||||
}
|
||||
items.push(item);
|
||||
}
|
||||
await Zotero.Items.loadDataTypes(items);
|
||||
|
||||
let matchedItems = new Set(items);
|
||||
if (options.searchString) {
|
||||
Zotero.debug("QuickFormat: Searching open tabs");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue