Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onchange patch #33

Merged
merged 5 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# v1.4.5
- Moved window reload logic to `then` instead of core settings `onchange` event. Fixes incompatibility between MM+ and Ftc
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be updated


# v1.4.4

- Now compatible with FVTT v10, thanks to @arcanist
Expand Down
12 changes: 8 additions & 4 deletions js/find-the-culprit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ function registerSetting() {
}

// Temporarily required by foundryvtt/foundryvtt#7740
Hooks.on("setup", () => {
/*Hooks.on("setup", () => {
if (game.release?.generation >= 10) {
game.settings.settings.get(`core.${ModuleManagement.CONFIG_SETTING}`).onChange =
foundry.utils.debouncedReload ?? window.location.reload;
}
});
});*/

Hooks.on("renderModuleManagement", onRenderModuleManagement);

Expand Down Expand Up @@ -354,7 +354,9 @@ async function deactivationStep(chosenModules = []) {
await game.settings.set(moduleName, "modules", currSettings);
}

game.settings.set("core", ModuleManagement.CONFIG_SETTING, original);
game.settings.set("core", ModuleManagement.CONFIG_SETTING, original).then(r => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is inside an asynchronous function, so it makes more sense to await this line and then put the reload on the next line without using then. This is more in line with modern JavaScript best practices.

return foundry.utils.debouncedReload() ?? window.location.reload
});;
}

async function reactivateModules() {
Expand All @@ -364,7 +366,9 @@ async function reactivateModules() {
);
for (let mod in curr.original) original[mod] = curr.original[mod];

game.settings.set("core", ModuleManagement.CONFIG_SETTING, original);
game.settings.set("core", ModuleManagement.CONFIG_SETTING, original).then(r => {
return foundry.utils.debouncedReload() ?? window.location.reload
});;
}

async function resetSettings() {
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"bugs": "https://github.com/Moerill/fvtt-find-the-culprit/issues",
"changelog": "https://github.com/Moerill/fvtt-find-the-culprit/blob/master/CHANGELOG.md",
"flags": {},
"version": "1.4.4",
"version": "1.4.5",
arcanistzed marked this conversation as resolved.
Show resolved Hide resolved
"compatibility": {
"minimum": "9",
"verified": "10"
Expand Down