Skip to content

Commit

Permalink
Improve muncher UI for spells and items on first run
Browse files Browse the repository at this point in the history
  • Loading branch information
MrPrimate committed Sep 13, 2023
1 parent 8e06303 commit 68e3a06
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/muncher/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ async function deleteCreateCompendiumItem(compendium, updateItem, existingItem)
DDBMuncher.munchNote(`Removing and Recreating ${updateItem.name} compendium entry`);
logger.debug(`Removing and Recreating ${updateItem.name} compendium entry`);
await existingItem.delete();
let newItem = createCompendiumItem(updateItem.type, compendium, updateItem);
let newItem = await createCompendiumItem(updateItem.type, compendium, updateItem);
return newItem;
}

Expand Down Expand Up @@ -182,7 +182,8 @@ async function createCompendiumItems(type, compendium, inputItems, index, matchF
const existingItems = await getFilteredItems(compendium, item, index, matchFlags);
// we have a single match
if (existingItems.length === 0) {
let newItem = createCompendiumItem(type, compendium, item);
// eslint-disable-next-line no-await-in-loop
let newItem = await createCompendiumItem(type, compendium, item);
promises.push(newItem);
}
};
Expand Down Expand Up @@ -257,6 +258,10 @@ export async function updateCompendium(type, documents, updateExisting = false,
const compendium = await CompendiumHelper.getCompendiumType(type);
compendium.configure({ locked: false });

if (compendium.metadata.type === "Item" && game.settings.get(SETTINGS.MODULE_ID, "munching-policy-delete-during-update")) {
await Item.deleteDocuments([], { pack: compendium.metadata.id, deleteAll: true });
}

if (game.user.isGM) {
const initialIndex = await compendium.getIndex();
// remove duplicate items based on name and type
Expand Down

0 comments on commit 68e3a06

Please sign in to comment.