0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-26 22:32:45 +00:00

Move fetchThemeBundle into /shared/helpers

This might not be the best rework - I was unsure if the *this* that would be available when called would see the appropriate object so I assumed not and pass it as a parameter.
Works, but may be bad form.
This commit is contained in:
David Bolack
2024-07-23 22:17:52 -05:00
parent 8e7baca47d
commit d2afa7adea
5 changed files with 22 additions and 54 deletions

View File

@@ -33,7 +33,18 @@ const printCurrentBrew = ()=>{
}
};
const fetchThemeBundle = (obj, renderer, theme)=>{
fetch(`${window.location.protocol}//${window.location.host}/theme/${renderer}/${theme}`).then((response)=>response.json()).then((themeBundle)=>{
themeBundle.joinedStyles = themeBundle.styles.map((style)=>`<style>${style}</style>`).join('\n\n'); //DOMPurify.sanitize(joinedStyles, purifyConfig);
obj.setState((prevState)=>({ // MOVE TO MOUNT STEP OF SHARE / NEW / EDIT
...prevState,
themeBundle : themeBundle
}));
});
};
module.exports = {
splitTextStyleAndMetadata,
printCurrentBrew
printCurrentBrew,
fetchThemeBundle,
};