Properties loading optimizations by KitCat

This commit is contained in:
Vlyan
2025-09-05 09:53:48 +02:00
parent eb675f24ea
commit 30455759e8
3 changed files with 19 additions and 23 deletions

View File

@@ -11,6 +11,7 @@ Date format : day/month/year
- Fix for fade configuration (!66) - Fix for fade configuration (!66)
- Added basic token conditions (Thanks to Putty) - Added basic token conditions (Thanks to Putty)
- Added ability to remove condition from actor sheet and core journal on click. - Added ability to remove condition from actor sheet and core journal on click.
- Added some Properties loading optimizations (!63 Thanks to KitCat).
## 1.13.0 - 24/08/2025 - Foundry v13 Compatibility (Thx to Litasa) ## 1.13.0 - 24/08/2025 - Foundry v13 Compatibility (Thx to Litasa)
__! Be certain to carefully back up any critical user data before installing this update !__ __! Be certain to carefully back up any critical user data before installing this update !__

View File

@@ -189,12 +189,12 @@ export class HelpersL5r5e {
// Unknown pack object, iterate all packs // Unknown pack object, iterate all packs
if (!document) { if (!document) {
for (const comp of game.packs) { await Promise.all(game.packs.map(async (comp) => {
const tmpData = await comp.getDocument(id); const tmpData = await comp.getDocument(id);
if (tmpData) { if (tmpData) {
document = HelpersL5r5e.createDocumentFromCompendium({ type, data: tmpData }); document = HelpersL5r5e.createDocumentFromCompendium({ type, data: tmpData });
} }
} }));
} }
// Final // Final

View File

@@ -37,31 +37,26 @@ export class ItemSheetL5r5e extends BaseItemSheetL5r5e {
* @private * @private
*/ */
async _prepareProperties(sheetData) { async _prepareProperties(sheetData) {
sheetData.data.propertiesList = []; sheetData.data.propertiesList = await Promise.all((sheetData.data?.system?.properties || []).map(async (property) => {
if (Array.isArray(sheetData.data.system.properties)) { const gameProp = await game.l5r5e.HelpersL5r5e.getObjectGameOrPack({ id: property.id, type: "Item" });
const props = []; if (gameProp) {
for (const property of sheetData.data.system.properties) { return gameProp;
const gameProp = await game.l5r5e.HelpersL5r5e.getObjectGameOrPack({ id: property.id, type: "Item" });
if (gameProp) {
sheetData.data.propertiesList.push(gameProp);
props.push({ id: gameProp.id, name: gameProp.name });
} else {
// Item not found
console.warn(`L5R5E | IS | Unknown property id[${property.id}], name[${property.name}]`);
sheetData.data.propertiesList.push({
id: property.id,
name: property.name,
type: "property",
img: "systems/l5r5e/assets/icons/items/property.svg",
removed: true,
});
}
} }
sheetData.data.system.properties = props;
} // Item not found
console.warn(`L5R5E | IS | Unknown property id[${property.id}], name[${property.name}]`);
return {
id: property.id,
name: property.name,
type: "property",
img: "systems/l5r5e/assets/icons/items/property.svg",
removed: true,
};
}));
} }
/** /**
* Subscribe to events from the sheet. * Subscribe to events from the sheet.
* @param {jQuery} html HTML content of the sheet. * @param {jQuery} html HTML content of the sheet.