earlSt1 / vtt-compendium-folders

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

Bug: compendium folders not shown #143

Closed farling42 closed 2 years ago

farling42 commented 2 years ago

Foundry version 269 Compendium Folder 2.4.4

The following error is reported in the console when opening up a compendium which already existed before updating the compendium folder to version 2.4.4

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'map')
[Detected 1 package: compendium-folders]
    at FICCache.loadCachedFolderStructure (fic-folders.js:431:44)
    at fic-folders.js:663:42
    at Hooks._call (foundry.js:294:14)
    at Hooks.call (foundry.js:279:33)
    at Compendium._render (foundry.js:3117:13)

The compendium is displayed without folders, and instead has lots of #[CF_tempEntity] entries displayed at the top of the list.

Pressing the "Fix Compendium" button did not fix the problem.

farling42 commented 2 years ago

Very weird. After trying this several times, as soon as I submitted the above bug report your module started working properly. It is possible that I opened a different compendium with folders before going back to the original compendium.

earlSt1 commented 2 years ago

Hi, thats strange, it looks like somehow when you first opened the compendium the cache didnt generate correctly. If you run into it again I'd be interested in the output of this macro if you could send it to me?

console.log(game.settings.get('compendium-folders','cached-folder'))

In the meantime to force the cache to regenerate you can use the following macro:

await game.CF.FICFolderAPI.clearCache();
farling42 commented 2 years ago

I can't be 100% certain, but this might have been in a compendium within a module which I updated, and the new version of the module had far more entries.

Would your cache from the previous launch of the world still be used next time the world is launched? If the same compendium was both the last opened before the restart and the first opened after the restart?

earlSt1 commented 2 years ago

Ahh, yes then in that case if you update a compendium through other means (like module updating) then the cache does not reset. Unfortunately I dont have a way of checking if the compendium changes this way, although a possible solution would be for me to reset the cache whenever the world loads in.....

I will look into testing this possble solution, but youre right, that is an edge case i hadnt considered and i'll prioritise it.

earlSt1 commented 2 years ago

This should be fixed in v2.4.5 now