Refactor the window re-rendering into a utility function
This commit is contained in:
parent
9d154cb303
commit
b4657d18f8
2 changed files with 15 additions and 3 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { reloadWindows } from "../utils.mjs";
|
||||||
import * as hbs from "../handlebars.mjs";
|
import * as hbs from "../handlebars.mjs";
|
||||||
|
|
||||||
Hooks.on(`hotReload`, async (data) => {
|
Hooks.on(`hotReload`, async (data) => {
|
||||||
|
|
@ -24,9 +25,7 @@ Hooks.on(`hotReload`, async (data) => {
|
||||||
_templateCache[templateName] = template;
|
_templateCache[templateName] = template;
|
||||||
|
|
||||||
// Re-render open windows
|
// Re-render open windows
|
||||||
for (const window of ui.windows) {
|
reloadWindows();
|
||||||
window.render(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
13
module/utils.mjs
Normal file
13
module/utils.mjs
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
export function reloadWindows(type = null) {
|
||||||
|
if (!type) {
|
||||||
|
for (const window of ui.windows) {
|
||||||
|
window.render(true);
|
||||||
|
};
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
for (const window of ui.windows) {
|
||||||
|
if (window instanceof type) {
|
||||||
|
window.render(true);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
Loading…
Add table
Add a link
Reference in a new issue