KayelGee / moar-folders

MIT License
2 stars 2 forks source link

Not working with v 11.300 #10

Open WiredKamikaze opened 1 year ago

WiredKamikaze commented 1 year ago

The number of folders is not increasing when in use with v11 Foundry. I installed and configured the desired amount of folders, and still nothing.

Not working in Foundry Stable Branch V. 11.300

TheGreatRedDuke commented 1 year ago

Confirmed, module does not seem to function in Foundry v11.305 in both the normal folder areas as well as in compendiums.

Creating folders (deeper than 4) throws an error:

Error: You may not nest Folders more than 4 levels deep.
    at Folder._preCreate (foundry.js:21922:62)
    at #preCreateDocumentArray (foundry.js:13507:31)
    at ClientDatabaseBackend._createDocuments (foundry.js:13394:73)
    at ClientDatabaseBackend.create (commons.js:8533:19)
    at async Folder.createDocuments (commons.js:7862:23)
    at async Folder.create (commons.js:7985:23)
    at async FolderConfig._updateObject (foundry.js:72435:13)
    at async FolderConfig._onSubmit (foundry.js:6597:7)
_onSubmit @ foundry.js:6600

In compendiums, no error is thrown, but Foundry simply won't let you create folders deeper than 3 deep.

I really hope you'll both be able to fix this and that it's is an easy adjustment for v11. This module makes my entire asset organization scheme possible.

KayelGee commented 1 year ago

I tried making it work, but I don't know how. I looked at the changes and it looks like just increasing the value in CONST.FOLDER_MAX_DEPTH should work, so I added the following code.

let newCONST = JSON.parse(JSON.stringify(CONST));
newCONST.FOLDER_MAX_DEPTH = FOLDER_MAX_DEPTH_MOAR_FOLDERS;
CONST = Object.freeze(newCONST);

But when you try to create a folder at depth 5+ the backend returns an error which I don't think can be patched with a module. So I guess this module is dead. Sorry about that.

TheGreatRedDuke commented 1 year ago

Sorry for the slow reply!!

Honestly, if you can make it so that the max folder/compendium folder depth is 5 and not 3 or 4. that would be amazing. At least for me, a 5 folder depth is as deep as I'd ever want to go and gives you a ton more flexibility in asset organization.

Would you be able to create a new version that works to 5 depth?

KayelGee commented 1 year ago

Sorry for the slow reply!!

Honestly, if you can make it so that the max folder/compendium folder depth is 5 and not 3 or 4. that would be amazing. At least for me, a 5 folder depth is as deep as I'd ever want to go and gives you a ton more flexibility in asset organization.

Would you be able to create a new version that works to 5 depth?

I'll quote myself

But when you try to create a folder at depth 5+ the backend returns an error which I don't think can be patched with a module. So I guess this module is dead. Sorry about that.

Weilef commented 1 year ago

My brother who is far more knowledgeable than me helped get mine working.

This is what he gave me.

Step 1. You can this as a replacement for the moar-folders java script file.

Object.defineProperty(WorldCollection.prototype, 'maxFolderDepth', {
  get: function () {
    return 999;
  }
});

const superPreCreate = Object.getPrototypeOf(Folder.prototype)._preCreate;
Folder.prototype._preCreate = function (data, options, user) {
  superPreCreate.call(this, data, options, user);
};

This change alone should allow you to view your folders, just not add new ones.

Step 2. Change this file "FoundryVTT\Foundry Virtual Tabletop\resources\app\dist\database\documents\folder.mjs" Open it and use the Replace text command on CONST.FOLDER_MAX_DEPTH and replace it with whatever folder depth number you wish. After doing this, you will be able to create folders.

KayelGee commented 1 year ago

Step 1 can be done in a module. Step 2 can't afaik. If you're doing Step 2 I don't understand why you would need Step 1 in the first place.

Weilef commented 1 year ago

Step 1 can be done in a module. Step 2 can't afaik. If you're doing Step 2 I don't understand why you would need Step 1 in the first place.

Right, one would have to manually adjust it for each Foundry update. Only doing step 1 is still great to be able to recover the lost folders.

At least for me, step 2 does not work for folder creation unless I enable step 1. However, I am not knowledgeable myself enough to explain why or how.

kaldigo commented 1 year ago

The problem is that even if you change the limit on the client side the server does do a check when saving to the db so there is no way to do it as a module. The best solution I have found so far is running this script whenever I update foundy.

docker exec -i foundryv11 sed -i 's/FOLDER_MAX_DEPTH = 4/FOLDER_MAX_DEPTH = 6/' /home/foundry/resources/app/common/constants.mjs
docker exec -i foundryv11 sed -i 's/FOLDER_MAX_DEPTH = 4/FOLDER_MAX_DEPTH = 6/' /home/foundry/resources/app/public/scripts/commons.js
docker restart foundryv11