0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-26 00:52:48 +00:00

Change fetchThemeBundle to not require this passed in.

`this` doesn't work with functional components
This commit is contained in:
Trevor Buckner
2025-08-20 16:25:54 -04:00
parent 90ceb52ffc
commit 4af33f6e75

View File

@@ -116,27 +116,21 @@ const printCurrentBrew = ()=>{
}
};
const fetchThemeBundle = async (obj, renderer, theme)=>{
const fetchThemeBundle = async (setError, setThemeBundle, renderer, theme)=>{
if(!renderer || !theme) return;
const res = await request
.get(`/api/theme/${renderer}/${theme}`)
.catch((err)=>{
obj.setState({ error: err });
setError(err)
});
if(!res) {
obj.setState((prevState)=>({
...prevState,
themeBundle : {}
}));
setThemeBundle({});
return;
}
const themeBundle = res.body;
themeBundle.joinedStyles = themeBundle.styles.map((style)=>`<style>${style}</style>`).join('\n\n');
obj.setState((prevState)=>({
...prevState,
themeBundle : themeBundle,
error : null
}));
setThemeBundle(themeBundle);
setError(null);
};
const debugTextMismatch = (clientTextRaw, serverTextRaw, label) => {