devMode json changed warning

I checked the module repo and I honestly can't figure out where I would plug in my code. I'd be guessing I'd be adding entirely new file like how the anchor and disable template cache do, but the existing folders make no sense for what this would be about.
C
Calego960d ago
How often are you running this fetch? your code, for reference:
fetch(`systems/${game.system.id}/template.json`, { method: 'GET', cache: 'no-cache', redirect: 'manual'})
.then(function (response) {
if (response.ok) response.json().then(data => {
const diff = diffObject(game.system.template, data);
if (!isObjectEmpty(diff)) {
ui.notifications?.warn("template.json has changed", {permanent:true});
console.warn("template.json has changed:", diff);
}
})
});
fetch(`systems/${game.system.id}/template.json`, { method: 'GET', cache: 'no-cache', redirect: 'manual'})
.then(function (response) {
if (response.ok) response.json().then(data => {
const diff = diffObject(game.system.template, data);
if (!isObjectEmpty(diff)) {
ui.notifications?.warn("template.json has changed", {permanent:true});
console.warn("template.json has changed:", diff);
}
})
});
This is something which would be independant, part of one of the classes, potentially a new class altogether to fully contain this functionality. It'll need this fetch as a method, and some trigger, as well as a way to disable/enable the functionality via a setting.
M
Mana960d ago
My test was just set to run it at ready hook.
C
Calego960d ago
If it can run on a hook, a new files in hooks is good you're thinking "on reload, check if the json is different and you should go back to setup?" I like that
M
Mana960d ago
Yeah. I don't think it makes much sense otherwise since I don't think you can reload JS without doing evil sorcery.
UU
Unknown User960d ago
C
Calego960d ago
you could set it to re-check on a timeout but that's kind of awful
UU
Unknown User960d ago
C
Calego960d ago
UX wise, init or ready barely matters, the user still has to go back to setup manually
M
Mana960d ago
I like ready myself to avoid it from interfering with the initial load too much. Same reason I've pushed my template preloading there in all my other projects.
C
Calego960d ago
👍 Here's all you should need to get this set up in dev mode: A new file in hooks which looks like the dev-mode-anchor one, but will end up a lot simpler/smaller. A new setting to enable this And a tweak to foundryvtt-devMode.mjs to tie it all together
M
Mana960d ago
Problem tho. This works flawlessly when developing a system, but if you're module developer. How would I determine which module.json to test? It looks like devMode doesn't allow determining which itself. Only decent option I can think of is not to actually do it in ready hook and just expose two functions, one for doing it for a module (module.json), the other for system (system.json & template.json). Or introduce new setting where you just type down module ID
C
Calego960d ago
IMO it's fine if iteration 1 of this is only geared towards systems Setting would be "warn me if my system json changes" (default off)
M
Mana960d ago
Alright.
UU
Unknown User960d ago
M
Mana960d ago
Hmm.. possibly.
UU
Unknown User960d ago
M
Mana960d ago
Honestly what I have so far would make adding testing all active modules fairly trivial...
C
Calego960d ago
Feels like a lot of fetches to me but sure yeah I guess it won't hurt anything, esp since it happens asynchronously in the hook
M
Mana960d ago
For developing stuff, it should only be ~3 at most, unless you develop with tons of modules enabled.
C
Calego960d ago
<.< i feel attacked 😛
M
Mana960d ago
Also, the JSON files are tiny, and likely you're doing this locally anyway (not guaranteed). I'll add two booleans, one for testing system, the other for testing modules.
C
Calego960d ago
👍
M
Mana960d ago
Or select box.
C
Calego960d ago
thanks @manaflower !
LTL
Leo The League Lion960d ago
@calego gave vote LeaguePoints™ to @manaflower (#88 • 13)
UU
Unknown User960d ago
M
Mana960d ago
Well, there's a bump in the road for non template.json checking. Foundry apparently reformats module.json description, so if you happen to have say <br/> in there, it will always trigger as if it had been modified. Same applies to system.json I imagine. I'll just do the template.json comparison and leave the extended code in with some comments about why it's not enabled.
DT
Daniel Thorp960d ago
Would a button in the notification for shutting down the game be appropriate here?
M
Mana960d ago
It's not going to pop up a dialog, just normal notification. Dialog would be far too intrusive as it's not something you HAVE to restart for (depending what you're doing). Except for Foundry reformatting the description, this is so far working for all other data. I guess I could just delete description comparison...
C
Calego960d ago
There's probably a method out there that does this sanitation, maybe you can find that and run it before diffing? Part of moduleData document maybe
M
Mana960d ago
Considering the problem seems to only occur with description, I just deleted it from diffing. I don't think anyone particularly cares for the description of their module/system changing.
M
Mana960d ago
GitHub
JSON change notifications by mkahvi · Pull Request #21 · League-of-...
Adds two options to be notified of either system JSON (system.json &amp; template.json) changes or module JSON (module.json) changes. The introduced code should be fairly easy to extend or fix ...
M
Mana960d ago
Not entirely sure about the import in the main .mjs file, but it should be fine. I guess the fetchData should've been named differently, too. Ugh. Loaded some 50 modules for testing that, so.. it should be fairly functional.
C
Calego960d ago
Awesome. Thanks @manaflower I'll give that a review soon ™️
LTL
Leo The League Lion960d ago
@calego gave vote LeaguePoints™ to @manaflower (#83 • 14)
C
Calego954d ago
@manaflower I uh.. completely forgot about this. But I just pushed a review your way. A few small tweaks and this is golden.
M
Mana954d ago
Committed the changes. I have no idea how these things work. Click the re-request review? I have no clue.
C
Calego954d ago
i gotchu rerequesting review is a good idea yeah merged and released!
C
Calego954d ago
used new GH auto changelog in the release too, very shiny
No description
M
Mana954d ago
Neat.
C
Calego954d ago
somehow the workflow for release failed... wondering if this is a github bug, gonna investigate later
Want results from more Discord servers?
Add your server
More Posts
S3 File Picker SettingsCan someone with an S3 configuration give me a test of the FilePicker settings api and tell me if a item preCreate@sol.folango @mrprimate (pinging you two in particular because you do import stuff involving existinItem Macro Compendium WorkflowOkay, here's a long one that's a bit of a doozy. I'm looking at setting up some sort of tooling/workItem Specific Crit DetailsOh that critical hit thing is gonna hit MRE too isn't it... hrm...1.5.x 72%@dnd5e No action required (but suggested 🙂 ) The 1.5.0 milestone is ~72% complete. It has a due daV9 Tabs IssueIf you never figured this out, here's why this happened: A small change in `Tabs` during v9 causes sDeck Creation MacroI created a macro to fill out a 52-card deck, you set the ID of the deck and the base URL of the foldevmode-issues@arcanist figured out, the flex layout elements have `pointer-events: none`, so anything injected wifunction vs methodAnyone know of a good guide that explains the difference between a function and a method? I don't reActive Effect HelpAnd it should be the actual ActiveEffect document for the effect, not just the id. I don't have theTOL JEs@badgerwerks I haven't had a chance to poke around in TOB/BoL yet, but I wanted to ask how you did tCI 2 minute windowAlright, I've got a Gitlab CI pipeline I'm reasonably pleased with as a result of yesterday's effortGitLab CI PipelinesToday's project is Gitlab CI. Wow me with your pipelines if you got em.Storybook Shennanegins@wyrmisis I have a headcannon for you, one who also uses Storybook. _What if_ we could load foundryjsxDammit I want this...react librarySo far I've seen Vue 2, Vue 3, Alpine, and Svelte pulled into Foundry. No one has yet been crazy enoweb componentsA comment @n1xx1 made over in #development-basics (https://discord.com/channels/732325252788387980/7UI element JS Classeshttps://discord.com/channels/732325252788387980/734922093967310910/882979923483037696 @wyrmisis > Imid-milestone ping feedback@dnd5e **No Action Required** Wanted to ping you to make you aware that the 1.5.0 milestone is >50%Hot ReloadingIs there a way to do something like hot module reloading/live reloading on change for Foundry?