0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-02 17:12:45 +00:00

Changes fetchThemeBundle helper to not need "this" parameter

Looks a bit ugly but this is temporary toward converting edit/home/new into functional components
This commit is contained in:
Trevor Buckner
2025-08-30 19:02:39 -04:00
parent 7198c21229
commit 518a3434be
6 changed files with 18 additions and 32 deletions

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) => {