diff --git a/changelog.md b/changelog.md index 34a04757..ad42bd63 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,10 @@ # Item Piles Changelog +## Version 3.0.5 + +- Fixed issue in Foundry v11 that would cause item piles to not refresh when items and currencies were taken from them, allowing users to take multiple items +- Fixed bug with giving item always giving 1 item + ## Version 3.0.4 - Fixed random-ish errors when duplicating item piles and then trying to open their interfaces diff --git a/src/API/private-api.js b/src/API/private-api.js index 01fad17d..f0d7dcf9 100644 --- a/src/API/private-api.js +++ b/src/API/private-api.js @@ -1846,8 +1846,6 @@ export default class PrivateAPI { if (user?.active || gms.length || game.user.isGM) { - dropData.itemData.quantity = 1; - if (PileUtilities.canItemStack(dropData.itemData.item)) { let itemQuantity = Utilities.getItemQuantity(item); if ((!itemQuantity || itemQuantity <= 0)) { @@ -1858,7 +1856,11 @@ export default class PrivateAPI { dropData.itemData.quantity = await DropItemDialog.show(item, dropData.target.actor, { localizationTitle: "GiveItem" }); + } else if (!dropData.itemData.quantity) { + dropData.itemData.quantity = 1; } + } else { + dropData.itemData.quantity = 1; } Utilities.setItemQuantity(dropData.itemData.item, dropData.itemData.quantity); diff --git a/src/stores/item-pile-store.js b/src/stores/item-pile-store.js index 44a48bca..f5c8b1a9 100644 --- a/src/stores/item-pile-store.js +++ b/src/stores/item-pile-store.js @@ -148,9 +148,11 @@ export default class ItemPileStore { setupSubscriptions() { this.subscribeTo(this.document, () => { - const { renderData } = this.document.updateOptions; + const updateData = this.document.updateOptions; + const renderData = updateData?.renderData ?? updateData?.data ?? {}; if (foundry.utils.hasProperty(renderData, CONSTANTS.FLAGS.SHARING)) { this.shareData.set(SharingUtilities.getItemPileSharingData(this.actor)); + 13 this.refreshItems(); } if (foundry.utils.hasProperty(renderData, CONSTANTS.FLAGS.PILE)) { @@ -164,7 +166,8 @@ export default class ItemPileStore { if (this.recipientDocument) { this.subscribeTo(this.recipientDocument, () => { - const { renderData } = this.document.updateOptions; + const updateData = this.document.updateOptions; + const renderData = updateData?.renderData ?? updateData?.data ?? {}; if (foundry.utils.hasProperty(renderData, CONSTANTS.FLAGS.SHARING)) { this.recipientShareData.set(SharingUtilities.getItemPileSharingData(this.recipient)); this.refreshItems(); diff --git a/src/stores/pile-item.js b/src/stores/pile-item.js index 61c2034e..426925bf 100644 --- a/src/stores/pile-item.js +++ b/src/stores/pile-item.js @@ -91,7 +91,8 @@ export class PileItem extends PileBaseItem { }); this.subscribeTo(this.itemDocument, () => { - const { renderData } = this.itemDocument.updateOptions; + const updateData = this.itemDocument.updateOptions; + const renderData = updateData?.renderData ?? updateData?.data ?? {}; const itemData = CompendiumUtilities.findSimilarItemInCompendiumSync(this.item); this.name.set(itemData?.name ?? this.item.name); this.img.set(itemData?.img ?? this.item.img); @@ -253,7 +254,8 @@ export class PileAttribute extends PileBaseItem { }); this.subscribeTo(this.store.document, () => { - const { renderData } = this.store.document.updateOptions; + const updateData = this.store.document.updateOptions; + const renderData = updateData?.renderData ?? updateData?.data ?? {}; this.path = this.attribute.path; this.name.set(this.attribute.name); this.img.set(this.attribute.img); diff --git a/src/stores/vault-store.js b/src/stores/vault-store.js index a9601239..90e6704e 100644 --- a/src/stores/vault-store.js +++ b/src/stores/vault-store.js @@ -66,7 +66,8 @@ export class VaultStore extends ItemPileStore { }); this.subscribeTo(this.document, () => { - const { renderData } = this.document.updateOptions; + const updateData = this.document.updateOptions; + const renderData = updateData?.renderData ?? updateData?.data ?? {}; if (foundry.utils.hasProperty(renderData, CONSTANTS.FLAGS.LOG)) { this.processLogEntries(); }