mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 07:59:03 +01:00
Improved
This commit is contained in:
parent
f0a809266d
commit
e8343de4e4
4 changed files with 52 additions and 52 deletions
|
|
@ -247,16 +247,15 @@ export function getDocFromElement(element) {
|
|||
* @param {Array} changedItems The candidate changed list
|
||||
* @param {Array} currentItems The current list
|
||||
* @param {object} options Additional options which modify the update request
|
||||
* @param {string} optionsName The name of the options property holding the diff
|
||||
*/
|
||||
export function addLinkedItemsDiff(changedItems, currentItems, options, optionsName) {
|
||||
export function addLinkedItemsDiff(changedItems, currentItems, options) {
|
||||
if (changedItems) {
|
||||
const prevItems = new Set(currentItems);
|
||||
const newItems = new Set(changedItems);
|
||||
options[optionsName] = {
|
||||
toLink: Array.from(newItems.difference(prevItems).map(item => item?.item ?? item)),
|
||||
toUnlink: Array.from(prevItems.difference(newItems).map(item => item?.item?.uuid ?? item?.uuid ?? item))
|
||||
};
|
||||
options.toLink = Array.from(newItems.difference(prevItems).map(item => item?.item ?? item));
|
||||
options.toUnlink = Array.from(
|
||||
prevItems.difference(newItems).map(item => item?.item?.uuid ?? item?.uuid ?? item)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -264,20 +263,17 @@ export function addLinkedItemsDiff(changedItems, currentItems, options, optionsN
|
|||
* Adds or removes the current Application from linked document apps
|
||||
* depending on an update diff in the linked item list.
|
||||
* @param {object} options Additional options which modify the update requests
|
||||
* @param {string} optionName The prop name on options of the update diff
|
||||
* @param {object} sheet The application to add or remove from document apps
|
||||
*/
|
||||
export function updateLinkedItemApps(options, optionName, sheet) {
|
||||
if (options[optionName]) {
|
||||
options[optionName].toLink.forEach(featureUuid => {
|
||||
const doc = foundry.utils.fromUuidSync(featureUuid);
|
||||
doc.apps[sheet.id] = sheet;
|
||||
});
|
||||
options[optionName].toUnlink.forEach(featureUuid => {
|
||||
const doc = foundry.utils.fromUuidSync(featureUuid);
|
||||
delete doc.apps[sheet.id];
|
||||
});
|
||||
}
|
||||
export function updateLinkedItemApps(options, sheet) {
|
||||
options.toLink?.forEach(featureUuid => {
|
||||
const doc = foundry.utils.fromUuidSync(featureUuid);
|
||||
doc.apps[sheet.id] = sheet;
|
||||
});
|
||||
options.toUnlink?.forEach(featureUuid => {
|
||||
const doc = foundry.utils.fromUuidSync(featureUuid);
|
||||
delete doc.apps[sheet.id];
|
||||
});
|
||||
}
|
||||
|
||||
export const itemAbleRollParse = (value, actor, item) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue