Skip to content

Commit

Permalink
Fix item duplication on import
Browse files Browse the repository at this point in the history
  • Loading branch information
StasTserk committed Jul 14, 2023
1 parent 19b6378 commit 6462477
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions module/actors/sheets/BWActorSheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,18 @@ export class BWActorSheet<
}
}

async _onDropItem(
event: DragEvent,
data: object
// eslint-disable-next-line @typescript-eslint/no-explicit-any
): Promise<boolean | ActorSheet.OwnedItemData<any> | undefined> {
const dragData = data as helpers.ItemDragData;
if (dragData.actorId === this.actor.id) {
return false;
}
return await super._onDropItem(event, data);
}

getArmorDictionary(armorItems: Armor[]): { [key: string]: Armor | null } {
let armorLocs: { [key: string]: Armor | null } = {};
constants.armorLocations.forEach((al) => (armorLocs[al] = null)); // initialize locations
Expand Down
2 changes: 1 addition & 1 deletion module/dialogs/ImportItemDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ export async function addNewItem(options: AddItemOptions): Promise<unknown> {
await helpers.getItemsOfTypes(options.itemTypes as ItemType[])
).sort((a, b) => (a.name < b.name ? -1 : a.name === b.name ? 0 : 1));
const sourceList = ['World'].concat(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Array.from(game.packs?.values() || [])
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.filter((p: any) => p.visible)
.map((p: CompendiumCollection) => {
return helpers.compendiumName(p);
Expand Down
2 changes: 1 addition & 1 deletion module/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ export function getCompendiumList(): { name: string; label: string }[] {
game.packs?.contents || []
) as CompendiumCollection[];
return [{ name: 'world', label: 'World Content' }].concat(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
...packs
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.filter((p: any) => game.user?.isGM || p.visible)
.map((p) => {
return {
Expand Down

0 comments on commit 6462477

Please sign in to comment.