earlSt1 / vtt-compendium-folders

Collapsable folders in the compendium directory and folder structures inside compendiums for FoundryVTT
21 stars 18 forks source link

Error Deleting Folder in Compendium #74

Closed DivertedCircle closed 2 years ago

DivertedCircle commented 3 years ago

Getting the following error when trying to delete a folder in a compendium. The compendium closes when the errors pops and the folder doesn't delete. The folder was originally created by exporting to the compendium.

Uncaught (in promise) TypeError: parentEntity is undefined
    deleteFolderWithinCompendium https://assets.forge-vtt.com/bazaar/modules/compendium-folders/2.3.1/compendium-folders.js:1252

Foundry Version 0.8.6 DnD5e Version 1.3.3 Compendium Folders Version 2.3.1

earlSt1 commented 3 years ago

Hi, can you try running this macro (after changing the compendium name to the compendium you are using) and sending me the output? I'm working on a way to auto-detect issues like this:

let contents = await game.packs.contents.find(x => x.metadata.label === 'PFS1e Journal Entries').getDocuments();
let folders = contents.filter(x => x.name === game.CF.TEMP_ENTITY_NAME)
let entities = contents.filter(x => x.name != game.CF.TEMP_ENTITY_NAME)

for (let entity of entities){
    if (entity.data?.flags?.cf?.path){
        let path = entity.data.flags.cf.path
        let parentEntity = contents.find(x => x.name === game.CF.TEMP_ENTITY_NAME && x.data.flags.cf.path === path);
        if (parentEntity == null){
            console.log("Not sure what to do for "+entity.name+" with path '"+path+"'")
        } else if (entity.data.flags.cf.id != parentEntity.data.flags.cf.id){
            console.log('Need to update parent folder ID for '+entity.name+' to '+parentEntity.data.flags.cf.id);
        }
    }
}
for (let folder of folders){
    let folderPath = folder.data.flags.cf.folderPath;
    let newFolderPath = folderPath;
    let path = folder.data.flags.cf.path;
    for (let folderId of folderPath){
        if (!contents.some(x => x.name === game.CF.TEMP_ENTITY_NAME && x.data.flags.cf.id === folderId)){
            let correctFolder = contents.find(x => x.name === game.CF.TEMP_ENTITY_NAME && x.data.flags.cf.path === path);
            if (correctFolder)
                console.log('Need to update index '+folderPath.indexOf(folderId)+' of folderPath for folder '+folder.data.flags.cf.id+' to '+correctFolder.data.flags.cf.id);
            else
                console.log('Not sure what to do for folder '+folder.data.flags.id+' with folderPath '+folderPath)
        }
    }
}
DivertedCircle commented 3 years ago

Changing the name of the compendium to match my 'Class Features' compendium and running the macro is just telling me the macro has a syntax error. ReferenceError: assignment to undeclared variable entity anonymous https://assets.forge-vtt.com/bazaar/modules/advanced-macros/1.6/Macros.js line 168 > Function:9 Macros.js:213:13 executeMacro https://assets.forge-vtt.com/bazaar/modules/advanced-macros/1.6/Macros.js:213

earlSt1 commented 3 years ago

My bad, ive updated my comment with the correct macro now

DivertedCircle commented 3 years ago

Object { _id: "Iq9ryNy6ZwkwPdgK", name: "New Macro", type: "script", author: "4o1SkXeZVPjWDy2Z", img: "icons/svg/dice-target.svg", scope: "global", command: "let contents = await game.packs.contents.find(x => x.metadata.label === 'Class Features').getDocuments();\nlet folders = contents.filter(x => x.name === game.CF.TEMP_ENTITY_NAME)\nlet entities = contents.filter(x => x.name != game.CF.TEMP_ENTITY_NAME)\n\nfor (let entity of entities){\n    if (entity.data?.flags?.cf?.path){\n        let path = entity.data.flags.cf.path\n        let parentEntity = contents.find(x => x.name === game.CF.TEMP_ENTITY_NAME && x.data.flags.cf.path === path);\n        if (parentEntity == null){\n            console.log(\"Not sure what to do for \"+entity.name+\" with path '\"+path+\"'\")\n        } else if (entity.data.flags.cf.id != parentEntity.data.flags.cf.id){\n            console.log('Need to update parent folder ID for '+entity.name+' to '+parentEntity.data.flags.cf.id);\n        }\n    }\n}\nfor (let folder of folders){\n    let folderPath = folder.data.flags.cf.folderPath;\n    let newFolderPath = folderPath;\n    let path = folder.data.flags.cf.path;\n    for (let folderId of folderPath){\n        if (!contents.some(x => x.name === game.CF.TEMP_ENTITY_NAME && x.data.flags.cf.id === folderId)){\n            let correctFolder = contents.find(x => x.name === game.CF.TEMP_ENTITY_NAME && x.data.flags.cf.path === path);\n            if (correctFolder)\n                console.log('Need to update index '+folderPath.indexOf(folderId)+' of folderPath for folder '+folder.data.flags.cf.id+' to '+correctFolder.data.flags.cf.id);\n            else\n                console.log('Not sure what to do for folder '+folder.data.flags.id+' with folderPath '+folderPath)\n        }\n    }\n}", folder: null, sort: 0, permission: {…}, … }
​
_id: "Iq9ryNy6ZwkwPdgK"
​
author: "4o1SkXeZVPjWDy2Z"
​
command: "let contents = await game.packs.contents.find(x => x.metadata.label === 'Class Features').getDocuments();\nlet folders = contents.filter(x => x.name === game.CF.TEMP_ENTITY_NAME)\nlet entities = contents.filter(x => x.name != game.CF.TEMP_ENTITY_NAME)\n\nfor (let entity of entities){\n    if (entity.data?.flags?.cf?.path){\n        let path = entity.data.flags.cf.path\n        let parentEntity = contents.find(x => x.name === game.CF.TEMP_ENTITY_NAME && x.data.flags.cf.path === path);\n        if (parentEntity == null){\n            console.log(\"Not sure what to do for \"+entity.name+\" with path '\"+path+\"'\")\n        } else if (entity.data.flags.cf.id != parentEntity.data.flags.cf.id){\n            console.log('Need to update parent folder ID for '+entity.name+' to '+parentEntity.data.flags.cf.id);\n        }\n    }\n}\nfor (let folder of folders){\n    let folderPath = folder.data.flags.cf.folderPath;\n    let newFolderPath = folderPath;\n    let path = folder.data.flags.cf.path;\n    for (let folderId of folderPath){\n        if (!contents.some(x => x.name === game.CF.TEMP_ENTITY_NAME && x.data.flags.cf.id === folderId)){\n            let correctFolder = contents.find(x => x.name === game.CF.TEMP_ENTITY_NAME && x.data.flags.cf.path === path);\n            if (correctFolder)\n                console.log('Need to update index '+folderPath.indexOf(folderId)+' of folderPath for folder '+folder.data.flags.cf.id+' to '+correctFolder.data.flags.cf.id);\n            else\n                console.log('Not sure what to do for folder '+folder.data.flags.id+' with folderPath '+folderPath)\n        }\n    }\n}"
​
flags: Object { "combat-utility-belt": {…}, "advanced-macros": {…} }
​
folder: null
​
img: "icons/svg/dice-target.svg"
​
name: "New Macro"
​
permission: Object { default: 0, 4o1SkXeZVPjWDy2Z: 3 }
​
scope: "global"
​
sort: 0
​
type: "script"
​
<prototype>: Object { … }
df-architect.js:25:3965

_id: "Iq9ryNy6ZwkwPdgK"
​
author: "4o1SkXeZVPjWDy2Z"
​
command: "let contents = await game.packs.contents.find(x => x.metadata.label === 'Class Features').getDocuments();\nlet folders = contents.filter(x => x.name === game.CF.TEMP_ENTITY_NAME)\nlet entities = contents.filter(x => x.name != game.CF.TEMP_ENTITY_NAME)\n\nfor (let entity of entities){\n    if (entity.data?.flags?.cf?.path){\n        let path = entity.data.flags.cf.path\n        let parentEntity = contents.find(x => x.name === game.CF.TEMP_ENTITY_NAME && x.data.flags.cf.path === path);\n        if (parentEntity == null){\n            console.log(\"Not sure what to do for \"+entity.name+\" with path '\"+path+\"'\")\n        } else if (entity.data.flags.cf.id != parentEntity.data.flags.cf.id){\n            console.log('Need to update parent folder ID for '+entity.name+' to '+parentEntity.data.flags.cf.id);\n        }\n    }\n}\nfor (let folder of folders){\n    let folderPath = folder.data.flags.cf.folderPath;\n    let newFolderPath = folderPath;\n    let path = folder.data.flags.cf.path;\n    for (let folderId of folderPath){\n        if (!contents.some(x => x.name === game.CF.TEMP_ENTITY_NAME && x.data.flags.cf.id === folderId)){\n            let correctFolder = contents.find(x => x.name === game.CF.TEMP_ENTITY_NAME && x.data.flags.cf.path === path);\n            if (correctFolder)\n                console.log('Need to update index '+folderPath.indexOf(folderId)+' of folderPath for folder '+folder.data.flags.cf.id+' to '+correctFolder.data.flags.cf.id);\n            else\n                console.log('Not sure what to do for folder '+folder.data.flags.id+' with folderPath '+folderPath)\n        }\n    }\n}"
​
flags: Object { "combat-utility-belt": {…}, "advanced-macros": {…} }
​
folder: null
​
img: "icons/svg/dice-target.svg"
​
name: "New Macro"
​
permission: Object { default: 0, 4o1SkXeZVPjWDy2Z: 3 }
​
scope: "global"
​
sort: 0
​
type: "script"
​
<prototype>: Object { … }```
earlSt1 commented 3 years ago

Alrighty, finished moving into new house and have internet and PC setup now.

Looks like you sent me the macro object somehow instead of the resulting object in the developer console. I just went through this with another user and found the easiest way is to right click the object created, and Copy Object. Then you can open notepad, paste it in there, then send it over. I'll follow this up with an image example of what i mean.

I plan on including a facility like this in the settings menu (along the lines of "My Compendiums are broken, help!", which automatically output the information I need).

earlSt1 commented 3 years ago

image

DivertedCircle commented 3 years ago

Running the macro again today gave me a different result. The first message is the error from when I tried to delete a folder in a compendium. After that is the macro results.


    deleteFolderWithinCompendium https://assets.forge-vtt.com/bazaar/modules/compendium-folders/2.3.1/compendium-folders.js:1252
compendium-folders.js:1252:9
20:24:18.489 Not sure what to do for War Domain Spells with path 'Cleric#/CF_SEP/War Domain Skills' Macros.js line 168 > Function:14:21
20:24:18.490 Not sure what to do for Channel Divinity with path 'Cleric#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.491 Not sure what to do for Infusion: Enhanced Weapon with path 'Artificer#/CF_SEP/Infusions' Macros.js line 168 > Function:14:21
20:24:18.491 Not sure what to do for Infusion: Resistant Armor with path 'Artificer#/CF_SEP/Infusions' Macros.js line 168 > Function:14:21
20:24:18.492 Not sure what to do for Artillerist Tool Proficiency with path 'Artificer#/CF_SEP/Artillerist Skills' Macros.js line 168 > Function:14:21
20:24:18.492 Not sure what to do for Ki: Balm of the Flame with path 'Monk#/CF_SEP/Way of the Argent Fist Skills' Macros.js line 168 > Function:14:21
20:24:18.493 Not sure what to do for Infusion: Quiver of Energy with path 'Artificer#/CF_SEP/Infusions' Macros.js line 168 > Function:14:21
20:24:18.493 Not sure what to do for Channel Divinity: Turn Undead with path 'Cleric#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.493 Not sure what to do for Infusion: Helm of Awareness with path 'Artificer#/CF_SEP/Infusions' Macros.js line 168 > Function:14:21
20:24:18.493 Not sure what to do for Timeless Body with path 'Monk#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.493 Not sure what to do for Ki-Empowered Strikes with path 'Monk#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.493 Not sure what to do for Infusion: Arcane Propulsion Armor with path 'Artificer#/CF_SEP/Infusions' Macros.js line 168 > Function:14:21
20:24:18.493 Not sure what to do for Extra Attack with path 'Monk#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.493 Not sure what to do for Infusion: Mind Sharpener with path 'Artificer#/CF_SEP/Infusions' Macros.js line 168 > Function:14:21
20:24:18.493 Not sure what to do for Channel Divinity: Harness Divine Power with path 'Cleric#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.493 Not sure what to do for Ki: Empty Body with path 'Monk#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.494 Not sure what to do for Infusion: Boots of the Winding Path with path 'Artificer#/CF_SEP/Infusions' Macros.js line 168 > Function:14:21
20:24:18.494 Not sure what to do for Infusion: Bane Weapon with path 'Artificer#/CF_SEP/Infusions' Macros.js line 168 > Function:14:21
20:24:18.494 Not sure what to do for Ki-Fueled Attack with path 'Monk#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.494 Not sure what to do for Hour of Reaping with path 'Monk#/CF_SEP/Way of the Long Death Skills' Macros.js line 168 > Function:14:21
20:24:18.494 Not sure what to do for Strike of the Coming Dawn with path 'Monk#/CF_SEP/Dualists Skills' Macros.js line 168 > Function:14:21
20:24:18.494 Not sure what to do for Purity of Body with path 'Monk#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.494 Not sure what to do for Blessed Strikes with path 'Cleric#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.494 Not sure what to do for Dedicated Weapon with path 'Monk#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.494 Not sure what to do for Gleaming Fists with path 'Monk#/CF_SEP/Way of the Argent Fist Skills' Macros.js line 168 > Function:14:21
20:24:18.494 Not sure what to do for Divine Intervention with path 'Cleric#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.494 Not sure what to do for Unarmored Defense with path 'Monk#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.494 Not sure what to do for Infusion: Silent Weapon with path 'Artificer#/CF_SEP/Infusions' Macros.js line 168 > Function:14:21
20:24:18.494 Not sure what to do for Ki: Focused Aim with path 'Monk#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.495 Not sure what to do for Tongue of the Sun and Moon with path 'Monk#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.495 Not sure what to do for Destroy Undead (CR 1/2) with path 'Cleric#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.495 Not sure what to do for Cantrip Versatility with path 'Cleric#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.495 Not sure what to do for Martial Arts with path 'Monk#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.495 Not sure what to do for Infusion: Radiant Weapon with path 'Artificer#/CF_SEP/Infusions' Macros.js line 168 > Function:14:21
20:24:18.495 Not sure what to do for - Monk with path 'Monk#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.495 Not sure what to do for Infusion: Replicate Magic Item: Additional Items with path 'Artificer#/CF_SEP/Infusions' Macros.js line 168 > Function:14:21
20:24:18.495 Not sure what to do for Infusion: Healing Salve with path 'Artificer#/CF_SEP/Infusions' Macros.js line 168 > Function:14:21
20:24:18.495 Not sure what to do for Infusion: Repeating Shot with path 'Artificer#/CF_SEP/Infusions' Macros.js line 168 > Function:14:21
20:24:18.495 Not sure what to do for Ki: Gleaming Wrath with path 'Monk#/CF_SEP/Way of the Argent Fist Skills' Macros.js line 168 > Function:14:21
20:24:18.495 Not sure what to do for Ki with path 'Monk#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.495 Not sure what to do for Cleric with path 'Cleric#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.496 Not sure what to do for Infusion: Returning Weapon with path 'Artificer#/CF_SEP/Infusions' Macros.js line 168 > Function:14:21
20:24:18.496 Not sure what to do for Perfect Self with path 'Monk#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.496 Not sure what to do for Twin Souls with path 'Monk#/CF_SEP/Dualists Skills' Macros.js line 168 > Function:14:21
20:24:18.496 Not sure what to do for Infusion: Spell-Refueling Ring with path 'Artificer#/CF_SEP/Infusions' Macros.js line 168 > Function:14:21
20:24:18.496 Not sure what to do for Cleric Spellcasting with path 'Cleric#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.496 Not sure what to do for Infusion: Enhanced Defense with path 'Artificer#/CF_SEP/Infusions' Macros.js line 168 > Function:14:21
20:24:18.496 Not sure what to do for War Priest with path 'Cleric#/CF_SEP/War Domain Skills' Macros.js line 168 > Function:14:21
20:24:18.496 Not sure what to do for Ki: Patient Defense with path 'Monk#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.496 Not sure what to do for Slow Fall with path 'Monk#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.496 Not sure what to do for War Domain Bonus Proficiencies with path 'Cleric#/CF_SEP/War Domain Skills' Macros.js line 168 > Function:14:21
20:24:18.496 Not sure what to do for Channel Divinity: War God's Blessing with path 'Cleric#/CF_SEP/War Domain Skills' Macros.js line 168 > Function:14:21
20:24:18.497 Not sure what to do for Channel Divinity: Guided Strike with path 'Cleric#/CF_SEP/War Domain Skills' Macros.js line 168 > Function:14:21
20:24:18.497 Not sure what to do for Avatar of Battle with path 'Cleric#/CF_SEP/War Domain Skills' Macros.js line 168 > Function:14:21
20:24:18.497 Not sure what to do for Infusion: Resistance Breaker with path 'Artificer#/CF_SEP/Infusions' Macros.js line 168 > Function:14:21
20:24:18.497 Not sure what to do for Unarmed Strike with path 'Monk#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.497 Not sure what to do for Infusion: Replicate Magic Item with path 'Artificer#/CF_SEP/Infusions' Macros.js line 168 > Function:14:21
20:24:18.497 Not sure what to do for Ki: Step of the Wind with path 'Monk#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.497 Not sure what to do for Ki: Diamond Soul with path 'Monk#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.497 Not sure what to do for Unarmored Movement with path 'Monk#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.497 Not sure what to do for Touch of Death with path 'Monk#/CF_SEP/Way of the Long Death Skills' Macros.js line 168 > Function:14:21
20:24:18.497 Not sure what to do for Infusion: Armor of Magical Strength with path 'Artificer#/CF_SEP/Infusions' Macros.js line 168 > Function:14:21
20:24:18.497 Not sure what to do for Infusion: Fortify Defense with path 'Artificer#/CF_SEP/Infusions' Macros.js line 168 > Function:14:21
20:24:18.497 Not sure what to do for Ki: Quickened Healing with path 'Monk#/CF_SEP/Class Skills' Macros.js line 168 > Function:14:21
20:24:18.498 Not sure what to do for Improved Critical with path 'Fighter#/CF_SEP/Champion' Macros.js line 168 > Function:14:21
20:24:18.498 Not sure what to do for The Ol' Temple Two Step with path 'Monk#/CF_SEP/Dualists Skills' Macros.js line 168 > Function:14:21
20:24:18.498 Not sure what to do for Night Falls and the Coming Dawn with path 'Monk#/CF_SEP/Dualists Skills' Macros.js line 168 > Function:14:21
20:24:18.498 Not sure what to do for Seeker of the Light with path 'Monk#/CF_SEP/Way of the Argent Fist Skills' Macros.js line 168 > Function:14:21
20:24:18.498 Need to update index 0 of folderPath for folder temp_w874nwcmdlr to temp_r0vmjqj14in Macros.js line 168 > Function:28:25
20:24:18.498 Need to update index 0 of folderPath for folder temp_htuomh3ida to temp_r0vmjqj14in Macros.js line 168 > Function:28:25
20:24:18.498 Need to update index 0 of folderPath for folder temp_bzostlw9cbt to temp_r0vmjqj14in Macros.js line 168 > Function:28:25
20:24:18.499 Need to update index 0 of folderPath for folder temp_idikvb7krls to temp_r0vmjqj14in Macros.js line 168 > Function:28:25
20:24:18.499 Need to update index 0 of folderPath for folder temp_4lfqc3e6lm to temp_r0vmjqj14in Macros.js line 168 > Function:28:25
20:24:18.499 Need to update index 0 of folderPath for folder temp_f0uf59jo0ye to temp_r0vmjqj14in Macros.js line 168 > Function:28:25
20:24:18.499 Need to update index 0 of folderPath for folder temp_pj4bo6mk1w to temp_r0vmjqj14in Macros.js line 168 > Function:28:25
20:25:03.085 Foundry VTT | Synchronized official game time in 51ms foundry.js:1457:13```
earlSt1 commented 3 years ago

Ok, step 1 done. Can you also run this macro too? (this is the one you need to Copy Object on, was getting confused). This will give me all the folder data for your compendium entries.

let entries = await game.packs.contents.find(x => x.metadata.label === 'PFS1e Journal Entries').getDocuments();
let output = entries.map(e => foundry.utils.mergeObject({entryId:e._id,entryName:e.name},e.data?.flags?.cf));
console.log(output);

Did you make this compendium a while ago or was it made recently?

DivertedCircle commented 3 years ago

Here's the output: https://pastebin.com/qK2sKtAv. This compendium is probably 2+ months old.

earlSt1 commented 3 years ago

Great thanks. I can see whats gone wrong and have a macro that you can use that should fix it.

NOTE: I would strongly recommend duplicating your compendium, then running the macro on the new compendium, to see if it works ok. If it does you should be safe to run it on your original compendium

let pack = game.packs.get('world.test1234');
// Or use compendium name
//let pack = game.packs.contents.find(x => x.metadata.label === 'Test Compendium 1')
let updateList = [
    {
        id: 'Zq5sp52BPZFItFef',
        flags:{
            cf:{
                folderPath:[],
                path:"Rogue"
            }
        },
        id: 'bccybp4KCdkcjhPs',
        flags:{
            cf:{
                folderPath:[],
                path:"Artificer"
            }
        },
        id: 'h7d0erUOxQiOT3Es',
        flags:{
            cf:{
                folderPath:[],
                path:"Witch"
            }
        },
        id: 'uogsVRL9qezNTteu',
        flags:{
            cf:{
                folderPath:[],
                path:"Fighter"
            }
        },
        id: '1lgGWOTjFRChSnPt',
        flags:{
            cf:{
                folderPath:[],
                path:"Monk"
            }
        },
        id: 'R1NpfpaopWgkn7Lm',
        flags:{
            cf:{
                folderPath:[],
                path:"Cleric"
            }
        },
        id: 'Y71XSic1mgHbLgHh',
        flags:{
            cf:{
                folderPath:[],
                path:"Druid"
            }
        }
    }
]
for (let update of updateList){
    const document = await pack.getDocument(update.id);
    await document.update(update, {pack:pack.collection});
}
DivertedCircle commented 3 years ago

Hit a snag. When I try to duplicate the compendium I get the following error.

Uncaught (in promise) TypeError: pack.duplicate is not a function
    yes https://assets.forge-vtt.com/bazaar/modules/compendium-folders/2.3.2/compendium-folders.js:836
    callback https://expeditions-in-eberron.forge-vtt.com/scripts/foundry.js:20407
    submit https://expeditions-in-eberron.forge-vtt.com/scripts/foundry.js:20351
    _onClickButton https://expeditions-in-eberron.forge-vtt.com/scripts/foundry.js:20314
    jQuery 2
        dispatch
        handle
compendium-folders.js:836:50
earlSt1 commented 3 years ago

gah, another bug from the looks of it. should have it fixed by tomorrow.

Another option is to backup the compendium on-disk in the meantime, then at least you can see if the macro works

earlSt1 commented 3 years ago

Ok fixed duplication issue. Can you uninstall CF and install using this manifest?

https://raw.githubusercontent.com/earlSt1/vtt-compendium-folders/082-update/test/module.json

DivertedCircle commented 3 years ago

What modifications does the macro need to make it specific to my game/compendium? Running it as is gives a syntax error.

earlSt1 commented 3 years ago

I dont see any syntax issues in my editor. Maybe it didn't copy right?

DivertedCircle commented 3 years ago

Tried copying it multiple ways. Running the macro exactly as you've posted it indicates there's a syntax error and gives the following console error. I'm wondering if there's parts of the macro I'm supposed to be changing.

    anonymous Macros.js line 167 > Function:62
    callScriptMacroFunction Macros.js:170
    renderMacro Macros.js:188
    executeMacro Macros.js:209
    _onClickMacro foundry.js:28001
    jQuery 9
    activateListeners foundry.js:27927
    _render foundry.js:2070
    call_wrapped libWrapper-wrapper.js:465
    <anonymous> listeners.js:75
    0 libWrapper-wrapper.js:160
    render foundry.js:2004
    render foundry.js:9900
    _onUpdateDocuments foundry.js:9984
    _handleUpdateDocuments foundry.js:8822
    _updateDocuments foundry.js:8707
    update backend.mjs:154
    updateDocuments document.mjs:365
    update document.mjs:447
    callOriginalFunction Monkey.js:80
    patchCompendiumUpdateEntity patches.js:100
    _updateObject foundry.js:3252
    _updateObject foundry.js:25591
    _onSubmit foundry.js:2818
    _activateCoreListeners foundry.js:2756
    _render foundry.js:2069
    call_wrapped libWrapper-wrapper.js:465
    <anonymous> listeners.js:75
    0 libWrapper-wrapper.js:160
    _render foundry.js:2729
    render foundry.js:2004
    render foundry.js:3223
    callback df-architect.js:25
    render foundry.js:20207
    jQuery 9
Macros.js:212:13
earlSt1 commented 2 years ago

Hi, sorry for the wait. I've been working on a compendium fixer that should automatically repair your compendium. It's live on my test environment if you want to give it a go? I tested it locally with a few compendiums and it seemed to work ok.

The workflow for this new process is:

  1. Duplicate your problematic compendium
  2. Select Fix Compendium in the module settings
  3. Select the duplicated compendium
  4. You should get a dialog displaying all the issues with your compendium. a. Take a screenshot of this just to be safe
  5. Click Attempt to Fix a. If you see a notification at the top of the screen saying "Repair Complete" or something, then it should have worked. b. If not, and something is wrong, then you should get a popup with some error messages which will help me if you send them over 😄

This is still a work in progress, but once done then people can use this utility to hopefully auto-fix their compendiums.

To install the testing version, uninstall your current version of compendium folders and install this one using the manifest link at the bottom of the install module screen: https://raw.githubusercontent.com/earlSt1/vtt-compendium-folders/082-update/test/module.json

DivertedCircle commented 2 years ago

Not getting a dialogue, just an error. This is happening as soon as I click Validate.

    updateEntityParentIfInvalid compendium-folders.js:2727
    validateCompendium compendium-folders.js:2656
    _updateObject compendium-folders.js:2645
    _onSubmit foundry.js:2818
    _activateCoreListeners foundry.js:2756
    _render foundry.js:2069
    call_wrapped libWrapper-wrapper.js:465
    <anonymous> listeners.js:75
    _render#0 libWrapper-wrapper.js:160
    _render foundry.js:2729
    render foundry.js:2004
    onClickSubmenuWrapper colorSetting.js:20
    call_wrapper libWrapper-wrapper.js:549
    _onClickSubmenu#0 libWrapper-wrapper.js:162
    jQuery 2
        dispatch
        handle
compendium-folders.js:2727:17
    validateCompendium compendium-folders.js:2709
    InterpretGeneratorResume self-hosted:1482
    AsyncFunctionNext self-hosted:692
    (Async: async)
    _updateObject compendium-folders.js:2645
    _onSubmit foundry.js:2818
    _onSubmit self-hosted:1175
    (Async: EventHandlerNonNull)
    _activateCoreListeners foundry.js:2756
    _render foundry.js:2069
    AsyncFunctionNext self-hosted:692
    (Async: async)
    call_wrapped libWrapper-wrapper.js:465
    call_wrapped self-hosted:1279
    <anonymous> listeners.js:75
    wrapper self-hosted:1222
    _render#0 libWrapper-wrapper.js:160
    _render foundry.js:2729
    render foundry.js:2004
    onClickSubmenuWrapper colorSetting.js:20
    call_wrapper libWrapper-wrapper.js:549
    _onClickSubmenu#0 libWrapper-wrapper.js:162
    _onClickSubmenu#0 self-hosted:1175
    jQuery 2
        dispatch
        handle
earlSt1 commented 2 years ago

Hmm ok i think i see the problem. Can you try uninstall + reinstall using the same method? I think i need to update folders first before the entities.

DivertedCircle commented 2 years ago

That sorta worked. I had to reload the world before a newly duplicated compendium would appear in the list but after that it ran and gave me a dialogue saying no errors found. Still got the error below when trying to delete a folder in that compendium after validating.

12:54:02.302 Uncaught (in promise) TypeError: parentEntity is undefined
    deleteFolderWithinCompendium https://expeditions-in-eberron.forge-vtt.com/modules/compendium-folders/compendium-folders.js:1254
compendium-folders.js:1254:9
    deleteFolderWithinCompendium https://expeditions-in-eberron.forge-vtt.com/modules/compendium-folders/compendium-folders.js:1328
    InterpretGeneratorResume self-hosted:1482
    AsyncFunctionNext self-hosted:692
earlSt1 commented 2 years ago

Gotcha, can you try reinstall once more? getting a better idea of whats wrong with your compendium. You may find after the fix is applied that some entries are no longer in folders (it looks like for some reason you're missing a folder in the compendium).

DivertedCircle commented 2 years ago

Getting a new error when hitting Validate now and no dialogue pop up.

13:15:47.560 Uncaught (in promise) TypeError: "" is not a function
    validateCompendium https://expeditions-in-eberron.forge-vtt.com/modules/compendium-folders/compendium-folders.js:2720
compendium-folders.js:2720:27
    validateCompendium https://expeditions-in-eberron.forge-vtt.com/modules/compendium-folders/compendium-folders.js:2718
    InterpretGeneratorResume self-hosted:1482
    AsyncFunctionNext self-hosted:692
earlSt1 commented 2 years ago

Sorry, I did realise a few minutes after updating that i misspelled a variable, you may have the older version, could you update again? Also it may be easier to switch to discord if you want? I dont mind either way

DivertedCircle commented 2 years ago

Still getting the error after uninstalling and reinstalling. Messaged you on Discord.

earlSt1 commented 2 years ago

Helped fix this through discord messages. Now have a Fix My Compendium feature in 2.3.4. Closing for now