Skip to content

Commit

Permalink
minor fixes for v10
Browse files Browse the repository at this point in the history
  • Loading branch information
Haxxer committed Sep 26, 2022
1 parent de108be commit 5a2e58f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/API/private-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default class PrivateAPI {
* @private
*/
static _onCreateItem(doc) {
//debugger;
if (!doc.parent) return;
ItemPileStore.notifyChanges("createItem", doc.parent, doc);
if (!PileUtilities.isValidItemPile(doc.parent)) return;
Expand All @@ -61,6 +62,7 @@ export default class PrivateAPI {
* @private
*/
static _onUpdateItem(doc) {
//debugger;
if (!doc.parent) return;
if (!PileUtilities.isValidItemPile(doc.parent)) return;
this._evaluateItemPileChange(doc.parent);
Expand All @@ -70,6 +72,7 @@ export default class PrivateAPI {
* @private
*/
static _onDeleteItem(doc) {
//debugger;
if (!doc.parent) return;
ItemPileStore.notifyChanges("deleteItem", doc.parent, doc);
if (!PileUtilities.isValidItemPile(doc.parent)) return;
Expand Down
16 changes: 8 additions & 8 deletions src/applications/merchant-app/MerchantPopulateItemsTab.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@
const tableDraw = await table.drawMany(timesRolled, { displayChat: false });
itemsRolled.update((items) => {
tableDraw.results.forEach((result) => {
const rollData = result.data;
const rollData = result;
const existingItem = items.find(
(item) => item.resultId === rollData.resultId
(item) => item.documentId === result.documentId
);
if (existingItem) {
existingItem.quantity++;
Expand Down Expand Up @@ -120,12 +120,12 @@
async function getItem(itemToGet) {
let item;
if (itemToGet.collection === "Item") {
item = game.items.get(itemToGet.resultId);
if (itemToGet.documentCollection === "Item") {
item = game.items.get(itemToGet.documentId);
} else {
const compendium = game.packs.get(itemToGet.collection);
const compendium = game.packs.get(itemToGet.documentCollection);
if (compendium) {
item = await compendium.getDocument(itemToGet.resultId);
item = await compendium.getDocument(itemToGet.documentId);
}
}
return item;
Expand All @@ -144,7 +144,7 @@
function removeItem(itemToRemove) {
itemsRolled.update((items) => {
const existingItemIndex = items.findIndex(
(item) => item.resultId === itemToRemove.resultId
(item) => item.documentId === itemToRemove.documentId
);
items.splice(existingItemIndex, 1);
return items;
Expand Down Expand Up @@ -356,7 +356,7 @@
</div>
{#if $itemsRolled.length}
{#each $itemsRolled as item (item.resultId)}
{#each $itemsRolled as item (item.documentId)}
<div
class="item-piles-flexrow item-piles-item-row item-piles-even-color"
>
Expand Down
3 changes: 2 additions & 1 deletion src/stores/merchant-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default class MerchantStore extends ItemPileStore {

const filterDebounce = foundry.utils.debounce(() => {
this.refreshItems();
}, 100);
}, 200);
this.subscribeTo(this.typeFilter, (val) => {
if (!val) return;
filterDebounce()
Expand Down Expand Up @@ -245,6 +245,7 @@ class PileMerchantItem extends PileItem {
if (hasProperty(data, CONSTANTS.FLAGS.ITEM)) {
this.itemFlagData.set(PileUtilities.getItemFlagData(this.item));
this.refreshDisplayQuantity();
this.store.refreshItems();
}
if (hasProperty(data, CONSTANTS.FLAGS.ITEM + ".prices") || hasProperty(data, game.itempiles.API.ITEM_PRICE_ATTRIBUTE)) {
this.refreshPriceData();
Expand Down
1 change: 0 additions & 1 deletion src/stores/pile-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ export class PileItem extends PileBaseItem {
}
}


take() {
const quantity = Math.min(get(this.currentQuantity), get(this.quantityLeft));
if (!quantity) return;
Expand Down

0 comments on commit 5a2e58f

Please sign in to comment.