0.7.2 1-Jan-2022

Remove deprecated variables
Check for isFoundryv8Plus
features_update
opus1217 2022-01-01 21:27:33 -08:00
parent d789f150ab
commit 62c64e432f
2 changed files with 19 additions and 15 deletions

View File

@ -48,11 +48,12 @@
Uses some built-ins for minor performance improvement Uses some built-ins for minor performance improvement
12-Sep-2021 0.7.1 Issue #25 Initialization fails because of corrupted settings 12-Sep-2021 0.7.1 Issue #25 Initialization fails because of corrupted settings
Fix: Check for settings.loadedSpellCompendium and settings.loadedNpcCompendium Fix: Check for settings.loadedSpellCompendium and settings.loadedNpcCompendium
1-Jan-2022 0.7.2 Switch to isFoundryV8Plus class variable
*/ */
const CMPBrowser = { const CMPBrowser = {
MODULE_NAME : "compendium-browser", MODULE_NAME : "compendium-browser",
MODULE_VERSION : "0.7.1", MODULE_VERSION : "0.7.2",
MAXLOAD : 500, //Default for the maximum number to load before displaying a message that you need to filter to see more MAXLOAD : 500, //Default for the maximum number to load before displaying a message that you need to filter to see more
} }
@ -175,7 +176,7 @@ class CompendiumBrowser extends Application {
return false; return false;
} }
event.dataTransfer.setData("text/plain", JSON.stringify({ event.dataTransfer.setData("text/plain", JSON.stringify({
type: pack.entity, type: pack.documentName,
pack: pack.collection, pack: pack.collection,
id: li.getAttribute("data-entry-id") id: li.getAttribute("data-entry-id")
})); }));
@ -492,7 +493,7 @@ class CompendiumBrowser extends Application {
try{ try{
//Filter the full list, but only save the core compendium information + displayed info //Filter the full list, but only save the core compendium information + displayed info
for (let pack of game.packs) { for (let pack of game.packs) {
if (pack['metadata']['entity'] === "Item" && this.settings.loadedSpellCompendium[pack.collection].load) { if (pack.documentName === "Item" && this.settings.loadedSpellCompendium[pack.collection].load) {
//can query just for spells since there is only 1 type //can query just for spells since there is only 1 type
let query = {}; let query = {};
if (browserTab === "spell") { if (browserTab === "spell") {
@ -534,7 +535,7 @@ class CompendiumBrowser extends Application {
}.bind(this), compactItems); }.bind(this), compactItems);
} }
else if(browserTab == "feat"){ else if (browserTab === "feat"){
content.reduce(function(itemsList, item5e){ content.reduce(function(itemsList, item5e){
if (this.CurrentSeachNumber != seachNumber) throw STOP_SEARCH; if (this.CurrentSeachNumber != seachNumber) throw STOP_SEARCH;
@ -561,7 +562,7 @@ class CompendiumBrowser extends Application {
}.bind(this), compactItems); }.bind(this), compactItems);
} }
else if(browserTab == "item"){ else if (browserTab === "item"){
content.reduce(function(itemsList, item5e){ content.reduce(function(itemsList, item5e){
if (this.CurrentSeachNumber != seachNumber) throw STOP_SEARCH; if (this.CurrentSeachNumber != seachNumber) throw STOP_SEARCH;
@ -634,7 +635,7 @@ class CompendiumBrowser extends Application {
try{ try{
for (let pack of game.packs) { for (let pack of game.packs) {
if (pack['metadata']['entity'] == "Actor" && this.settings.loadedNpcCompendium[pack.collection].load) { if (pack.documentName == "Actor" && this.settings.loadedNpcCompendium[pack.collection].load) {
await pack.getDocuments().then(async content => { await pack.getDocuments().then(async content => {
content.reduce(function(actorsList, npc5e){ content.reduce(function(actorsList, npc5e){
@ -1187,13 +1188,13 @@ class CompendiumBrowser extends Application {
loadedNpcCompendium: {}, loadedNpcCompendium: {},
}; };
for (let compendium of game.packs) { for (let compendium of game.packs) {
if (compendium['metadata']['entity'] === "Item") { if (compendium.documentName === "Item") {
defaultSettings.loadedSpellCompendium[compendium.collection] = { defaultSettings.loadedSpellCompendium[compendium.collection] = {
load: true, load: true,
name: `${compendium['metadata']['label']} (${compendium.collection})` name: `${compendium['metadata']['label']} (${compendium.collection})`
}; };
} }
if (compendium['metadata']['entity'] === "Actor") { if (compendium.documentName === "Actor") {
defaultSettings.loadedNpcCompendium[compendium.collection] = { defaultSettings.loadedNpcCompendium[compendium.collection] = {
load: true, load: true,
name: `${compendium['metadata']['label']} (${compendium.collection})` name: `${compendium['metadata']['label']} (${compendium.collection})`
@ -1250,6 +1251,10 @@ class CompendiumBrowser extends Application {
console.log(defaultSettings); console.log(defaultSettings);
} }
this.settings = defaultSettings; this.settings = defaultSettings;
//0.9.5 Set the CompendiumBrowser.isFoundryV8Plus variable for different code-paths
//If v9, then game.data.version will throw a deprecation warning so test for v9 first
CompendiumBrowser.isFoundryV8Plus = (game.data.release?.generation >= 9) || (game.data.version?.startsWith("0.8"));
} }
saveSettings() { saveSettings() {
@ -1390,7 +1395,6 @@ class CompendiumBrowser extends Application {
} }
async addNpcFilters() { async addNpcFilters() {
const isFoundryV8 = game.data.version.startsWith("0.8");
// NPC Filters // NPC Filters
this.addNpcFilter(game.i18n.localize("CMPBrowser.general"), game.i18n.localize("DND5E.Source"), 'data.details.source', 'text'); this.addNpcFilter(game.i18n.localize("CMPBrowser.general"), game.i18n.localize("DND5E.Source"), 'data.details.source', 'text');
@ -1402,7 +1406,7 @@ class CompendiumBrowser extends Application {
//Foundry 0.8.x: Creature type (data.details.type) is now a structure, so we check data.details.types.value instead //Foundry 0.8.x: Creature type (data.details.type) is now a structure, so we check data.details.types.value instead
let npcDetailsPath; let npcDetailsPath;
if (isFoundryV8) { if (CompendiumBrowser.isFoundryV8Plus) {
npcDetailsPath = "data.details.type.value"; npcDetailsPath = "data.details.type.value";
} else {//0.7.x } else {//0.7.x
npcDetailsPath = "data.details.type"; npcDetailsPath = "data.details.type";

View File

@ -2,7 +2,7 @@
"name": "compendium-browser", "name": "compendium-browser",
"title": "Compendium Browser", "title": "Compendium Browser",
"description": "<p>Easily browse and filter spells, feats, items, and npcs loaded from compendia!</p><strong>NEW! Compendium Browser is faster and better-behaved;</strong> it no longer loads all the compendia into memory on start-up (which sometimes hung servers because of memory or CPU requirements). Instead, it filters and loads on-demand, as well as giving you a Module Setting to control how many rows are loaded at a time.<br>Changes in 0.7.0: Supports Foundry 0.8+ only; faster searches using Foundry 0.8 queries!", "description": "<p>Easily browse and filter spells, feats, items, and npcs loaded from compendia!</p><strong>NEW! Compendium Browser is faster and better-behaved;</strong> it no longer loads all the compendia into memory on start-up (which sometimes hung servers because of memory or CPU requirements). Instead, it filters and loads on-demand, as well as giving you a Module Setting to control how many rows are loaded at a time.<br>Changes in 0.7.0: Supports Foundry 0.8+ only; faster searches using Foundry 0.8 queries!",
"version": "0.7.1", "version": "0.7.2",
"author": "Spetzel#0103", "author": "Spetzel#0103",
"authors": [ "authors": [
{ {
@ -55,9 +55,9 @@
], ],
"url": "https://github.com/League-of-Foundry-Developers/compendium-browser", "url": "https://github.com/League-of-Foundry-Developers/compendium-browser",
"manifest": "https://github.com/League-of-Foundry-Developers/compendium-browser/releases/latest/download/module.json", "manifest": "https://github.com/League-of-Foundry-Developers/compendium-browser/releases/latest/download/module.json",
"download": "https://github.com/League-of-Foundry-Developers/compendium-browser/releases/download/v0.7.1/compendium-browser.zip", "download": "https://github.com/League-of-Foundry-Developers/compendium-browser/releases/download/v0.7.2/compendium-browser.zip",
"minimumCoreVersion": "0.8.6", "minimumCoreVersion": "0.8.6",
"compatibleCoreVersion": "0.8.9", "compatibleCoreVersion": "9",
"allowBugReporter": true, "allowBugReporter": true,
"bugs": "https://github.com/League-of-Foundry-Developers/compendium-browser/issues", "bugs": "https://github.com/League-of-Foundry-Developers/compendium-browser/issues",
"readme": "https://github.com/League-of-Foundry-Developers/compendium-browser/blob/master/README.md", "readme": "https://github.com/League-of-Foundry-Developers/compendium-browser/blob/master/README.md",