mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
Improved item-identicial check
This commit is contained in:
parent
5d0a59bd12
commit
3c9bbf770c
2 changed files with 10 additions and 3 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { itemIsIdentical } from '../../../helpers/utils.mjs';
|
||||
import DHBaseActorSettings from './actor-setting.mjs';
|
||||
import DHApplicationMixin from './application-mixin.mjs';
|
||||
|
||||
|
|
@ -248,9 +249,7 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
|
|||
});
|
||||
}
|
||||
|
||||
const existingItem = this.document.items.find(
|
||||
x => x._stats.compendiumSource === actorItem._stats.compendiumSource
|
||||
);
|
||||
const existingItem = this.document.items.find(x => itemIsIdentical(x, dropDocument));
|
||||
if (existingItem) {
|
||||
cancel = true;
|
||||
await existingItem.update({
|
||||
|
|
|
|||
|
|
@ -437,3 +437,11 @@ export function shuffleArray(array) {
|
|||
|
||||
return array;
|
||||
}
|
||||
|
||||
export function itemIsIdentical(a, b) {
|
||||
const compendiumSource = a._stats.compendiumSource === b._stats.compendiumSource;
|
||||
const name = a.name === b.name;
|
||||
const description = a.system.description === b.system.description;
|
||||
|
||||
return compendiumSource && name & description;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue