Update compendium-browser.js

master
Matheus Clemente 2024-02-27 21:03:56 -03:00
parent 626454c411
commit 373bca7663
1 changed files with 0 additions and 40 deletions

View File

@ -3,7 +3,6 @@ import { dnd5eProvider } from "./providers/dnd5e.js";
import { registerSettings } from "./settings.js"; import { registerSettings } from "./settings.js";
const STOP_SEARCH = "StopSearchException"; const STOP_SEARCH = "StopSearchException";
const NOT_MIGRATED = "NotMigratedException";
const COMPENDIUM_BROWSER = "compendium-browser"; const COMPENDIUM_BROWSER = "compendium-browser";
class CompendiumBrowser extends Application { class CompendiumBrowser extends Application {
@ -591,7 +590,6 @@ class CompendiumBrowser extends Application {
) )
), ),
]; ];
let collectionName = "unknown";
try { try {
for (let pack of game.packs) { for (let pack of game.packs) {
if (pack.documentName === "Actor" && this.settings.loadedNpcCompendium[pack.collection].load) { if (pack.documentName === "Actor" && this.settings.loadedNpcCompendium[pack.collection].load) {
@ -606,11 +604,6 @@ class CompendiumBrowser extends Application {
npc5e.img = game.dnd5e.moduleArt.map.get(npc5e.uuid.replace(".Actor", ""))?.actor; npc5e.img = game.dnd5e.moduleArt.map.get(npc5e.uuid.replace(".Actor", ""))?.actor;
} }
if (npc5e.system === undefined) {
collectionName = pack.collection;
throw NOT_MIGRATED;
}
numNpcsLoaded = Object.keys(npcs).length; numNpcsLoaded = Object.keys(npcs).length;
if (this.maxLoad <= numNpcsLoaded) { if (this.maxLoad <= numNpcsLoaded) {
@ -653,8 +646,6 @@ class CompendiumBrowser extends Application {
} catch(e) { } catch(e) {
if (e === STOP_SEARCH) { if (e === STOP_SEARCH) {
// breaking out // breaking out
} else if (e === NOT_MIGRATED) {
console.log("Cannot browse compendium %s as it is not migrated to v10 format", collectionName);
} else { } else {
throw e; throw e;
} }
@ -1127,37 +1118,6 @@ class CompendiumBrowser extends Application {
return true; return true;
} }
// incomplete removal of duplicate items
removeDuplicates(spellList) {
// sort at n log n
let sortedList = Object.values(spellList).sort((a, b) => a.name.localeCompare(b.name));
// search through sorted list for duplicates
for (let index = 0; index < sortedList.length - 1; ) {
// all duplicates will be next to eachother
if (sortedList[index].name === sortedList[index + 1].name) {
// duplicate something is getting removed
// TODO choose what to remove rather then the second
let remove = index + 1;
delete spellList[sortedList[remove].id];
sortedList.splice(remove, 1);
} else {
index++;
}
}
}
clearObject(obj) {
let newObj = {};
for (let key in obj) {
if (obj[key] === true) {
newObj[key] = true;
}
}
return newObj;
}
// FILTERS - Added on the Ready hook // FILTERS - Added on the Ready hook
// 0.4.0 Make this async so filters can be added all at once // 0.4.0 Make this async so filters can be added all at once
async addFilter(entityType, category, label, path, type, possibleValues = null, valIsArray = false) { async addFilter(entityType, category, label, path, type, possibleValues = null, valIsArray = false) {