Aedif / TokenVariants

GNU General Public License v3.0
17 stars 12 forks source link

Error when trying to Configure Settings #75

Closed PhyDoesStuff closed 1 year ago

PhyDoesStuff commented 1 year ago

Foundry version: v9, build 269 Module Version: 3.3.2 System, version: Pathfinder 2nd Edition, 3.12.2.10

When attempting to configure settings while logged in via the Foundry app, I see the following error in the console:

foundry.js:319 TypeError: Cannot read properties of undefined (reading 'join')
    at configureSettings.js:67
    at Array.map (<anonymous>)
    at ConfigureSettings.getData (configureSettings.js:61)
    at ConfigureSettings._render (foundry.js:3062)
    at ConfigureSettings._render (foundry.js:3764)
    at ConfigureSettings.render (foundry.js:3021)
    at ExtendedSettingsConfig._onClickSubmenu (foundry.js:55705)
    at HTMLButtonElement.dispatch (jquery.min.js:2)
    at HTMLButtonElement.v.handle (jquery.min.js:2)

When attempting the same thing with the same user in Firefox, I instead get the following errors:

TypeError: path.types is undefined
    paths http://localhost:30001/modules/token-variants/applications/configureSettings.js:67
    getData http://localhost:30001/modules/token-variants/applications/configureSettings.js:61
    _render http://localhost:30001/scripts/foundry.js:3062
    _render http://localhost:30001/scripts/foundry.js:3764
    render http://localhost:30001/scripts/foundry.js:3021
    _onClickSubmenu http://localhost:30001/scripts/foundry.js:55705
    jQuery 2
[foundry.js:319:30](http://localhost:30001/scripts/foundry.js)
    onError http://localhost:30001/scripts/foundry.js:319
    render http://localhost:30001/scripts/foundry.js:3023
    (Async: promise callback)
    render http://localhost:30001/scripts/foundry.js:3021
    _onClickSubmenu http://localhost:30001/scripts/foundry.js:55705
    jQuery 2

Followed by two instances of a promise timeout error

Uncaught (in promise) Error: Timed Out
    HttpError http://localhost:30001/common/utils/http.mjs:65
    fetchWithTimeout http://localhost:30001/common/utils/http.mjs:28

I've used a previous version of this module with custom paths, and updating to 2.3.2 seems to have broken something. I've uninstalled and reinstalled the plugin via the Foundry application, but I'm not sure if there was something left behind elsewhere, as the issue persists.

executing game.modules.get("token-variants").api.TVA_CONFIG.searchPaths in the console returns a 2-length array of Strings, not Objects: ['modules/caeora-maps-tokens-assets/assets/tokens/', 'strength-of-thousands-characterArt']

I know I started using this module quite a few versions ago, so I'd guess searchPaths' expected form changed at some point. I plan to do game.modules.get("token-variants").api.TVA_CONFIG.searchPaths = [] to reset the paths, but it looks like the array could benefit from some additional checks, or forcing it to empty in the wacky case that it's just an array of strings.

PhyDoesStuff commented 1 year ago

Executing game.modules.get("token-variants").api.TVA_CONFIG.searchPaths = [] yields a different error when attempting to access the config menu immediately after:

TypeError: Cannot create property 'label' on string ''
    at ConfigureSettings.getData (configureSettings.js:75)
    at ConfigureSettings._render (foundry.js:3062)
    at ConfigureSettings._render (foundry.js:3764)
    at ConfigureSettings.render (foundry.js:3021)
    at ExtendedSettingsConfig._onClickSubmenu (foundry.js:55705)
    at HTMLButtonElement.dispatch (jquery.min.js:2)
    at HTMLButtonElement.v.handle (jquery.min.js:2)

Additionally, restarting Foundry reverted my config back to the pre =[] state, which is super weird. I've attached both the config from after setting searchPaths = [], and then after restarting Foundry. token-variants-settings.txt token-variants-settings-after-restart.txt

I'm going to remove the module, restart Foundry, reinstall, and see what happens.

PhyDoesStuff commented 1 year ago

No luck with removing, restarting, and reinstalling. The old config is back and still broken. Is there somewhere the module is caching files?

Aedif commented 1 year ago

Hey, Sorry about these issues. I tried to convert the settings from previous version to a newer format but I guess I didn't test it throroughly enough. I didn't consider jumping x amount of versions ahead.

I can help you fix this. will require executing a few things in a macro/console.

Aedif commented 1 year ago

Run these two commands:

game.modules.get("token-variants").api.TVA_CONFIG.searchPaths = []

and

game.modules.get("token-variants").api.TVA_CONFIG.searchFilters = { "Portrait": { "include": "", "exclude": "", "regex": "", "label": "Portrait" }, "Token": { "include": "", "exclude": "", "regex": "", "label": "Token" }, "PortraitAndToken": { "include": "", "exclude": "", "regex": "", "label": "PortraitAndToken" }, "Tile": { "include": "", "exclude": "", "regex": "", "label": "Tile" }, "Item": { "include": "", "exclude": "", "regex": "", "label": "Item" }, "JournalEntry": { "include": "", "exclude": "", "regex": "", "label": "JournalEntry" }, "Macro": { "include": "", "exclude": "", "regex": "", "label": "Macro" }, "RollTable": { "include": "", "exclude": "", "regex": "", "label": "RollTable" } }

Then open the 'Configure Settings' window, and make sure to press 'Save Changes'

Aedif commented 1 year ago

Tell me if this works. I'll have to take another look at how I perform conversions between different versions of the settings. Your exports will be really useful when doing so.

PhyDoesStuff commented 1 year ago

Both of those together seems to do it! I can view the settings now, and am able to do so even after restarting Foundry. My Anadi player will be thrilled.

I exported my settings prior to starting and then after each step (though I goofed a bit and opened the settings window immediately after setting searchFilters, so that might mean some missing data). Hopefully, these give you some good additional info.

token-variants-settings-0.txt - start token-variants-settings-1.txt - after searchPaths token-variants-settings-2.txt - after searchFilters token-variants-settings-3.txt - after Save Changes token-variants-settings-4.txt - after restarting

Aedif commented 1 year ago

Thank you!

Aedif commented 1 year ago

Made some fixes and now as of release 3.4.0 old version settings such as yours will be properly converted when updating the module.